We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I2C and CAN not working in LPC1768 I am using two nos. LPC1768 header boards from different manufacturers. And if I try to communicate using I2C and CAN through both controllers, nothing is transmitting. But if I try to use UART on each controller and its working wonderful. Also whatever the I2C and CAN code written is working with other controllers which are of same manufacturers. I am not getting whats the wrong with these controllers and any hardware configuration to be changed. Also I want to know how to debug I2C protocol in this scenario and I don't have any oscilloscope or analyzer.
Hi Andrew Neil,
Thanks for your reply. I have tried with I2C LCD and that is also not communicating and I have tested the same code with another controllers and there its working. I have doubt that any pull-up resistors do I need to connect externally, because SDA and SCL pins are directly taken from LPC1768 IC to the external pins without any other component connected. Anyway I will follow your suggestions given in the above thread and try to do some additional work.
I have tested I2C based LCD and its working without any external pull-up resistors. And the I2C based LCD is working fine with the each micro-controller. Now I will try to check with both micro controllers connected with I2C. Anyway thanks for your support.
So that tells you that there must be internal pullups somewhere, then - doesn't it?
"the I2C based LCD is working fine with the each micro-controller"
So, in both of those cases, the microcontroller is being the Master - isn't it?
"I will try to check with both micro controllers connected with I2C"
For that, one of the microcontrollers will need to be a Slave - won't it?
And don't forget the pullups ...
""That is true. But I am thinking that pull-up resistors may be added in I2C LCD driver. And from my basic knowledge any one device must have pull-up resistors inorder to I2C bus to function. Because again if I tried with both microcontrollers, I2C between microcontrollers is not working.""
"the I2C based LCD is working fine with the each micro-controller" So, in both of those cases, the microcontroller is being the Master - isn't it?
""Yes. You are absolutely true. And only master program has been flashed to the microcontroller and LCD is like almost passive device to respond to the master transactions.""
"I will try to check with both micro controllers connected with I2C" For that, one of the microcontrollers will need to be a Slave - won't it?
""I have flashed one microcontroller with master-transmitter program and another microcontroller with slave-receiver program. But still I2C is not working between microcontrollers"".
""Please elaborate this last suggestion and I am not getting what exactly it is. And if want to add external pull-up resistors then what are the resistor values have to choose.""
I have connected external pull-up resistors (i.e. 4.7K-Ohm) in both SDA and SCL lines of I2C using board 3.3V supply. And now the I2C interface is working fine between two microcontrollers also. It seems to be I2C LCD driver might have included inbuilt pull-up resistors and that's the reason I2C LCD worked fine without any problem. Anyway thanks for your guidance and support.
Yes, that would seem the obvious conclusion from what you posted on 6-Nov-2018 18:04 GMT.
I am trying to use external interrupt with the following code using LPC1768 micro controller. I have connected P2.10 and P2.11 to switches and GPIO0 used to connect the LED's. When I press the switches no LED is going on Port 0. But after pressing reset the LEDs are glowing twice because of only reset button. And the code is shown below for your suggestion. I have posted in another thread but no one is helping and requesting to see this problem.
#include<LPC17xx.h> #define EXTMODE0 0 #define EXTMODE1 1 #define EXTPOLAR0 0 #define EXTPOLAR1 1 #define EINT0_PIN 20 #define EINT1_PIN 22 void delay(unsigned int value) { unsigned int i, j; for(i = 0; i < value; i++) for(j = 0; j < 2500; j++); } void EINT0_IRQHandler() { LPC_SC->EXTINT = (1<<0); //clearing interrupt bit LPC_GPIO0->FIOSET = 0xffffffff; delay(1000); LPC_GPIO0->FIOCLR = 0xffffffff; delay(1000); } void EINT1_IRQHandler() { LPC_SC->EXTINT = (1<<1); //clearing interrupt bit LPC_GPIO0->FIOSET = 0xffffffff; delay(1000); LPC_GPIO0->FIOCLR = 0xffffffff; delay(1000); } int main() { LPC_SC->EXTMODE = (0<<EXTMODE0)|(0<<EXTMODE1); //level-sensitive mode LPC_SC->EXTPOLAR = (0<<EXTPOLAR0)|(0<<EXTPOLAR1); //low active state LPC_PINCON->PINSEL4 = (1<<EINT0_PIN)|(1<<EINT1_PIN); //switches connected to P2.10 and P2.11 LPC_GPIO0->FIODIR = 0xffffffff; NVIC_EnableIRQ(EINT0_IRQn); NVIC_EnableIRQ(EINT1_IRQn); while(1); } </prep