NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
habibi
Posts: 7
0 Kudos

Read/write data using i2c/spi protocol

Hi everyone,

                 I am trying to read/write data from rtc ds1307 using i2c protocol but i am unable to read or write data.Here i am posting my code.I have tried both the codes but none of them are working.Can anyone please guide me?

Member
Sergiv
Posts: 74
0 Kudos

Re: Read/write data using i2c/spi protocol

Hi, habibi

try to use a delay of about 5 ms

45564.jpg 

 

 

 Now explain what is what:

1 -. address of the location at which to begin writing data.
2 -. directly to the data itself. we find that the F7 is written in a cell with address 0, F0 in a cell with address 1, F8 is written in the cell with address 2, etc.
3 -. address of the location at which to begin reading data.
4 -. number of cells that must be read
pursuant to paragraph 3 and 4 we read 2,3,4,5,6,7,8 cell
5 -. a slave address of your device (in this case, the memory chips). on page 5 of the above datasheet this address is given: 1010hhh (where x - depending on how you connect the memory. I 0). Then this is the address: 1010000, if translated into a 16-SS get 50.

Member
kentwong818
Posts: 3
0 Kudos

Re: Read/write data using i2c/spi protocol

Hi,

 

I am trying to do the same thing also, but the data read is always 255 (which is the default value i think?). What should i actually connect to the "write data" port? an array? or other things?

 

Best Regards,

Kent

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page