I'm developing a system who need to save some datas on external eeprom by I2C protocol and at the same time use the UART to comunicate to PC (by alternate pin). I'm using dsPIC30F4012 and EEPROM 24LC1025.
1° question is: Can I use UART and I2C at same time?
2° question is (if the 1° question was "YES"): why my program stop after when I try to write via I2C? The code is the following:
Code: Select all
dim address_H, address_L as byte
dim data_to_eeprom as byte
I2C1_Init(400000) ' initialize I2C communication
I2C1_Start() ' issue I2C start signal
I2C1_Write(0xA0) ' send byte via I2C (device address + W)
I2C1_Write(address_H) ' send byte (address of EEPROM location)
I2C1_Write(address_L) ' send byte (address of EEPROM location)
I2C1_Write(data_to_eeprom) ' send data (data to be written)
I2C1_Stop() ' issue I2C stop signal
I'm using the Timer3 to create a wave (so I can cheek the stability of system by a oscilloscope). When the program arrive to the line "I2C1_Write(0xA0) " he stop.
Anyone can help
Really thanks
Diego