View previous topic :: View next topic |
Author |
Message |
sunny Guest
|
I2C slave on 18F452 doesn't work |
Posted: Wed Jan 16, 2008 2:18 pm |
|
|
Hi all,
Currently I'm using a 18F452 for I2C slave, and I purchased Aardvark for emulating the I2C master. I tried the ex_slave.c example code, but it doesn't work. When I was trying to perform a write from the Aardvard, 0 byte was written. The interrupt doesn't seem to happen on 18F452 at all. I tried Aardvark with another board (Activity board) that comes with Aardvard and both the write and read work.
I'm using 3.3v system, on Aardvark there's 2.2k pullup resistor for both SCL and SDA lines.
My compiler version: 4.053. Code is just the example code.
Thanks for any comments. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jan 16, 2008 2:51 pm |
|
|
1. What is the Vdd voltage of the 18F452 board ?
2. What is the voltage used for the pull-up resistors ?
3. Are you using a 20 MHz crystal on the 18F452 board ?
4. Post the Aardvark code that you are using to write to the 18F452 board. |
|
|
Guest
|
|
Posted: Wed Jan 16, 2008 3:31 pm |
|
|
Hi PCM programmer, thanks for your response.
1. The Vdd on 18f452 board is 3.3V. Actually I also have a 5V board, it didn't work yesterday, so I thought maybe it's the different levels that caused the problem (Aardvark is using 3.3V), so today I made a 3.3V board, unfortunately doesn't work either.
2. The voltage for pull-up is 3.3V.
3. Yes, the clock is 20MHz.
4. Sorry I didn't use any code, I'm just using the GUI to perform the write. Maybe this is the problem? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
sunny Guest
|
|
Posted: Wed Jan 16, 2008 3:46 pm |
|
|
Thank you very much for the instruction. I'll try it later and let you know how it goes. |
|
|
sunny Guest
|
|
Posted: Thu Jan 17, 2008 1:09 pm |
|
|
Hi PCM Programmer,
I looked at the Aardvark GUI, seems those functionalities such as i2c_start(), i2c_write(address) are all integrated. When I want to perform a write, I just need to enter the slave address and data that I want to write in the corresponding window, and the GUI will do the rest. I couldn't see the sequence, nor can I manipulate it.
I also have a "Beagle" (from the same company) which is used to monitor the transaction. Seems the Aardvark performed the write, but the PIC didn't acknowlege (because it didn't enter the interrupt at all), so no byte is writen into the PIC. Again this is also a GUI, so I didn't see the voltage level, just the activity.
Do you or anyone else have any idea what the problem might be? Thanks a lot for any input!! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jan 17, 2008 2:11 pm |
|
|
Are you using their program called the "Control Center" ?
http://www.totalphase.com/products/aardvark/i2cspi/control-center/screenshot/?screen=0
If so, I think it's likely that they use the 7-bit format for the i2c
slave address. All the CCS example files use the 8-bit format.
This means that in the Ex_Slave.c file, the slave address is specified
as 0xA0. That's in 8-bit format. In 7-bit format, it becomes 0x50.
I suggest that you enter 0x50 into the Control Center program as
the slave address. See if that works. |
|
|
sunny Guest
|
|
Posted: Fri Jan 18, 2008 10:25 am |
|
|
Yes yes, that's the problem!
After I changed the address, I have the communication!!!
Thanks PCM Programmer, you are great!!! |
|
|
|