Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    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 :)
    Lawrie Griffiths
    @lawrie
    I am reading the data sheet and have now spotted it.
    OK, it is working now.
    Lawrie Griffiths
    @lawrie
    I did i2cset -y 0 0x6F 0x03 0x09
    Lawrie Griffiths
    @lawrie
    Or perhaps 0x0b for Tuesday, depending on how it is encoded.
    emard
    @emard
    I think from esp32 that it encodes from 1 as monday to 7 as sunday
    Lawrie Griffiths
    @lawrie
    So I should set 0x0a.
    emard
    @emard
    I think so from my memory :) I can also try to run esp32 NTP example to verify it.
    Lawrie Griffiths
    @lawrie
    I have started using fujprog -t, but it loses the connection a lot.
    emard
    @emard
    Perhaps it talks to ftdi in libusb mode hmmm. I dont remember now is -P the same as without (but before at ujprog it wasnt) so maybe -P/dev/ttyUSB0 -t could open port in unix standard mode, maybe that would be more reliable. But fujprog obviously has there a bug
    fujprog -P/dev/ttyUSB0 -t doesnt work
    ujprog -P/dev/ttyUSB0 -t works
    Lawrie Griffiths
    @lawrie
    oot@buildroot:~# cat date.sh 
    R6=`i2cget -y 0 0x6f 0x06`
    R5=`i2cget -y 0 0x6f 0x05`
    R4=`i2cget -y 0 0x6f 0x04`
    R2=`i2cget -y 0 0x6f 0x02`
    R1=`i2cget -y 0 0x6f 0x01`
    
    YY="${R6:2:2}"
    MON="$((${R5:2:2}-20))"
    DD="${R4:2:2}"
    HH="${R2:2:2}"
    MM="${R1:2:2}"
    
    echo "20$YY-$MON-$DD $HH:$MM"
    root@buildroot:~# ./date.sh 
    2020-9-22 19:40
    Lawrie Griffiths
    @lawrie
    date -s "`./date.sh`"
    emard
    @emard
    I have 12F updated everything from images but not the bitstream. my /dev/i2c-0 exists but i2cdetect wont detect anything. RTC works from ESP32 and FPGA i2c bridge. Do I need new 12F bitstream?
    (I think I have to download it :)
    Lawrie Griffiths
    @lawrie
    I believe so