
Registered on : 11-02-2008
Messages : 36
OFF-Line
|
Hi,
Trying my first I2C communication with AMR I have a problem.
Please have a look to my code: (based in IAR examples)
I2C_Init (I2C0);
I2C_FCLKConfig (I2C0);
I2C_OnOffConfig (I2C0, ENABLE);
I2C_SpeedConfig (I2C0, 100000);
I2C_AcknowledgeConfig (I2C0, ENABLE);
EIC_IRQConfig(DISABLE);
I2C_STARTGenerate(I2C0, ENABLE);
while (I2C_FlagStatus (I2C0, DIRECT, I2C_SB)==RESET);
I2C_AddressSend (I2C0,0xDE, I2C_Mode7, I2C_TX);
while (I2C_FlagStatus (I2C0, DIRECT, I2C_ENDAD)==RESET);
I2C_FlagClear (I2C0, I2C_ENDAD);
I2C_ByteSend (I2C0, 0x07);
while (I2C_FlagStatus (I2C0, DIRECT, I2C_BTF )==RESET);
I2C_STARTGenerate (I2C0, ENABLE);
while (I2C_FlagStatus (I2C0, DIRECT, I2C_SB)==RESET);
I2C_AddressSend (I2C0, 0xDF, I2C_Mode7, I2C_RX);
while (I2C_FlagStatus (I2C0, DIRECT, I2C_ENDAD)==RESET);
I2C_FlagClear (I2C0, I2C_ENDAD);
while (I2C_FlagStatus (I2C0, DIRECT, I2C_BTF )==RESET);
valor=I2C_ByteReceive (I2C0);
I2C_STOPGenerate (I2C0, ENABLE);
Having a look to signals on oscilloscope, transmission seems correct but STOP generation is not executed correctly (but program continue, don’t stop there)
Also, if I execute again the program without un-plug the board, nothing related with I2C is working correctly (even not START condition). SCL signal is always held up.
BTW, my slave is an ISL1209 (RTC) and I worked with this IC before with my old Microchip PICs without any problem.
I appreciate your help, I’m newbie with ARMs.
Thanks
Regards.
ALFA.
null
|
|
|