|
|
View previous topic :: View next topic |
Author |
Message |
josemb
Joined: 28 Mar 2015 Posts: 1
|
i2c master and slave logger: Multi-byte |
Posted: Sat Mar 28, 2015 8:10 pm |
|
|
WORKING I2C MASTER AND SLAVE LOGGER : MULTI-BYTE
http://www.ccsinfo.com/forum/viewtopic.php?t=21456
Hi all!,
I know that this is an old thread, but I hope that someone can help me. I am working with two PIC16F876A, one Master the other slave. Trying the code (changing the clock speed to 4MHz and including delays), if I enter any 16bit value, after the last digit i get the message "debug 1". If then I press Read, I get Value=0000 and "debug state 4 and 5. If I change the clock back to 20MHz then after writing a value I get "debug 5" (assume Ok?) but on reading the error message comes up. I am afraid I know very little about microcontrollers, only have made small projects so I am very sorry it. Can anyone tell me what I am missing?
Basically my project is as follows: on powering up both PICs, the slave must send 8 int16 values to the Master that he needs to do some stuff. Eventually the Master would send back another int16 result to the Slave. After finding this post I thought that I could modify it to get my goal.
I hope you can help, many thanks in advance! |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Sun Mar 29, 2015 5:29 am |
|
|
Why not just use the CCS supplied I2C functions ????
I'm NOT convinced his 'working code' actually works and in the time it took me to read it, I could have cut code using the I2C functions from CCS.
Also, why use 4Mhz clock? A 20MHz xtal is the same price and will give you 5 x more speed, allowing the PIC to do more !
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Sun Mar 29, 2015 5:45 am |
|
|
The code dates back ten years, to when there were problems with the I2C functions. For anything after perhaps the last eight years or so, the CCS functions have worked, and worked better. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|