Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Lawrie Griffiths
    @lawrie
    LOCATE COMP "system_hdmiPhy_gpdi_sda" SITE "B19"; # I2C shared with RTC
    LOCATE COMP "system_hdmiPhy_gpdi_scl" SITE "E12"; # I2C shared with RTC C12->E12
    Dolu1990
    @Dolu1990
    I was currently testing on arty A7, i'm now porting it to Ulx3s on those pins
    on ulx
    Lawrie Griffiths
    @lawrie
    @pnru_gitlab How do you think we should implement sleep in the lcc library?
    Dolu1990
    @Dolu1990
    For the RTC, is there anything special to configure on the board to get it alive on I2C ?
    should work without battery i guess
    emard
    @emard
    No board immediately has i2c to RTC. It is called in my constraints gpdi_sda, gpdi_scl. Its not only gpdi but it is shared bus with GPDI and RTC. Maybe I could just have called it i2c_sda i2c_scl :)
    Dolu1990
    @Dolu1990
    Rawrrr
    root@buildroot:~# i2cdetect -y 0
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
    00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
    10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 6f 
    70: -- -- -- -- -- -- -- --                         
    root@buildroot:~#
    emard
    @emard
    RTC completey works without battery but of course wont keep time after power off
    Yes 0x6F is RTCs address :)
    This is very promising for RTC and shutdown/wakeup capability :)
    Paul Ruiz
    @pnru_gitlab

    @pnru_gitlab How do you think we should implement sleep in the lcc library?

    See here for some ideas. Untested code.

    Dolu1990
    @Dolu1990
    apparently there is a driver in linux for that rtc (rtc-ds1307.c)
    emard
    @emard
    :) maybe a compatible enough one, as we have MCP7940N (microchip). Most of them RTC are very similar and have important time registers with equal meaning
    our RTC has to be initialized to start ticking. Power on default without battery is to "boot" as stopped.
    Dolu1990
    @Dolu1990
    got the rtc to start counting seconds and read it via :
    i2cset -y 0 0x6F 0x00 0x80
    sleep 4
    i2cget -y 0 0x6F 0x00
    emard
    @emard
    eheheheee it is great, it works!
    Uninitialized RTC outputs 32768Hz to boards internal wakeup pin. In this state board cant shutdown. RTC has to be initialized as alarm in future and its flag cleared, then it is possible that board sleeps in power off until alarm triggers
    Lawrie Griffiths
    @lawrie
    @pnru_gitlab Here is a test of your sleep code:
    #include <stdio.h>
    
    extern int sleep(int sec);
    extern int usleep(int usec);
    
    int main() {
      printf("Sleep for 2 seconds\n");
      sleep(2);
      printf("Sleep for 1M microseconds\n");
      usleep(1000000);
    
      return 0;
    }
    
    root@buildroot:~# time ./a.out
    Sleep for 2 seconds
    Sleep for 1M microseconds
    real    0m 3.02s
    user    0m 0.00s
    sys    0m 0.01s
    Dolu1990
    @Dolu1990
    I pushed the changes for i2c, it require saxon_netlist ; saxon_bitstream; saxon_buildroot_setup; saxon_buildroot_compile
    The sdcard should be completly reupdated.
    I2c mounted in /dev/i2c-0
    emard
    @emard
    Wonderful! I will have something to play :)
    It is not urgent but the proper time handing is what I always expect from each quality OS since DOS :)
    Paul Ruiz
    @pnru_gitlab
    @lawrie Great! I guess the official function prototypes are a bit different from what I have. sleep() uses unsigned int I believe, and sleep() takes a usecond_t type. In the end all the same bits of course.
    Lawrie Griffiths
    @lawrie
    @Dolu1990 @emard I have built a 12F version of the new SaxonSoc version and the i2cdetect works. I have fitted a battery to the clock.
    emard
    @emard
    WOOOWWWW i2c RTC :)))
    Lawrie Griffiths
    @lawrie
    I'll put it all in saxonsoc-ulx3s-bin
    Lawrie Griffiths
    @lawrie
    It is all in the Smp directory. The bistream is the 1core version. There is also a new version of riscv_lcc built on the host, rather than a copy of my manually built one, so not tested much.
    Lawrie Griffiths
    @lawrie
    The new riscv32_lcc does not include the top level riscv_32 directory, so you need to create that diredctory and extract it in that.
    Lawrie Griffiths
    @lawrie
    @emard Don't use the new riscv32_lcc. It is not correct.
    I have deleted iit and the updated bitstream is really there now.
    Lawrie Griffiths
    @lawrie
    @emard there is a new version of riscv32_lcc.tar.gz in Smp/images now. It has the top-level riscv32_lcc directory back and it appears to work now. It should have all the latest updates.
    Lawrie Griffiths
    @lawrie
    @emard I am trying to test whether my RTC keeps the time when I remove the power. Have I got the battery oin the right way? I have the flat side up, away from the board.
    Paul Ruiz
    @pnru_gitlab
    Yes, that is how i have it.
    Lawrie Griffiths
    @lawrie
    It does not seem to be maintaining the time when I unplug it.
    Paul Ruiz
    @pnru_gitlab
    Dud battery?
    Lawrie Griffiths
    @lawrie
    Just trying another one.
    Lawrie Griffiths
    @lawrie
    Which also doesn't seem to work. Should the oscillator keep running when the battery is installed so that setting register 0x00 to 0x80 should not be necessary?
    Paul Ruiz
    @pnru_gitlab
    On my board it just works and is in a running state when the power is restored. Did it work for you with the Cortex?
    Lawrie Griffiths
    @lawrie
    I did not try it on the Cortex.
    emard
    @emard
    @lawrie flat side (+) up to the metallic shell contact. smaller side (-) to PCB contact. Proper initialization makes RTC "tick" and remeber time. It is not just plug battery and it will start ftom 1970. I have not yet used lcc but now will download. You can take micropython i DVI example here to check battery etc is ok https://github.com/emard/ulx3s-misc/tree/master/examples/rtc/i2c_master/proj
    this one for initialization (it will set RTC to NTP time using esp32) https://github.com/emard/ulx3s-misc/tree/master/examples/rtc/micropython-mcp7940n
    Paul Ruiz
    @pnru_gitlab
    How are you accessing it, esp32 or SaxonSoc? Is it possible that either one shuts the RTC down on repowering?
    Lawrie Griffiths
    @lawrie
    I am using the i2cset and i2cget commands on SaxonSoc.
    ESP32 is not directly connected to RTC so it can only talk to RTC thru FPGA inbetween
    RTC has register flag that indicated "keep time if battery present" This flag must be initialized. otherwise, even battery is there,, power off and RTC will forget :)
        self._i2c.writeto_mem(MCP7940.ADDRESS, 0x03, bytes([0x07 | 8])) # weekday | battery_backup
    its hidden in the weekday :)