CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

I2C slave on 18F452 doesn't work

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
sunny
Guest







I2C slave on 18F452 doesn't work
PostPosted: Wed Jan 16, 2008 2:18 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jan 16, 2008 2:51 pm     Reply with quote

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








PostPosted: Wed Jan 16, 2008 3:31 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jan 16, 2008 3:44 pm     Reply with quote

Make the GUI emulate the functionality of this master code:
http://www.ccsinfo.com/forum/viewtopic.php?t=32368&start=3
sunny
Guest







PostPosted: Wed Jan 16, 2008 3:46 pm     Reply with quote

Thank you very much for the instruction. I'll try it later and let you know how it goes.
sunny
Guest







PostPosted: Thu Jan 17, 2008 1:09 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jan 17, 2008 2:11 pm     Reply with quote

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







PostPosted: Fri Jan 18, 2008 10:25 am     Reply with quote

Yes yes, that's the problem!

After I changed the address, I have the communication!!!

Thanks PCM Programmer, you are great!!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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