Hello,
I am writing an I2C master transmitter object. The problem I am having is that the IRQ Handler for I2C1 is not firing. According to the manual, it should fire after the start condition is sent and the status register is 0x08. When I step through the code with the debugger, the status code is 0x08. I am using an MCB1700 development board. Why is it not firing? Did I not configure something properly? For tests, All I am doing is toggling an LED on when the interrupt fires. Once I solve this problem, I will write the rest of the code.
#include <stdio.h> #include <LPC17XX.h> #include "GPIO1Output.h" GPIO1Output out(P1_28); __irq void I2C1_IRQHandler(void) { if (LPC_I2C1->I2STAT == 0x08) { out.Set(); } } int main(void) { // Initialize I2C. LPC_PINCON->PINSEL0 = 0x0F; LPC_PINCON->PINMODE_OD0 = 0x03; NVIC_EnableIRQ(I2C1_IRQn); LPC_I2C1->I2CONSET = 0x40; LPC_I2C1->I2CONSET = 0x20; int status = LPC_I2C1->I2STAT; }
Did you set any breakpoint in your ISR?
Are you making sure that whatever reason you get into the ISR are resulting in the interrupt source being cleared?
I did put breakpoints in the ISR. They are never reached.
Did you power the i2c peripheral?
In the configuration wizard for the system_LPC17xx.c there is a check by the I2C1 in the Power Control for Perepherials Register (PCONP), so yes, power is enabled here. Is there something else? I disabled power to all perepherials I am not using.
Where in the ISR did you set your breakpoint?
If an interrupt doesn't happen, then the single-stepping would normally continue as normal. If the processor does not continue to single-step, then you have to consider problems with stack space for the interrupt, or that you do reach the interrupt but get jumped to another place than you thought. Or that you reach the ISR again and again and again because you don't clear the interrupt.
Single stepping is working fine. That means the interrupt is not firing. There must be something I am not setting up right. I also tried one of the other I2C channels. No Cigar.
You probably did, but did indeed follow the "basic configuration" procedure described in the NXP user manual? NXP offer a sample code bundle at the LPC1768 page that build with uv4.
Maybe you are using a non-standard startup file that calls the i2c interrupt function differently? Do other interrupts work?
Funny that you ask, do other interrupts work. The answer is no. Other ones do not work either. At the link is a picture of my startup files. Are they not standard?
imageshack.us/.../
Take the startup files of a working Keil example for the MCB1700. Overwrite yours. What happens?
The interrupts work when I overwrite one of Keil's examples. When I started the project, a wizard ran in Keil that placed the startup_LPC17xx.h file. I manually placed the startup_LPC17xx.c from the startup directory otherwise I would not be able to call anything. Is there anything I should have done differently here?
I met to say the wizard placed the startup_LPC17xx.s file, not the the startup_LPC17xx.h file.
Don't waste your time. Run a diff between the projects and correct in your own sources.
The projects contain older versions of the files. Merging them with mine will cause other problems. Is there a document that says how to properly create a project so that everything will function properly?
Here is the project. I do not wish to rely on other projects just to allow interrupts to work. That startup file does contain definitions for all the IRQ service routines but they somehow are not linking. My entire project is available for download here:
www.filedropper.com/firmware
So how can you properly configure this simple project?
OK, here is the lowndown:
The most recent version of the files do not work! The core_cm3.c file version 1.20, the LPC17xx.c 1.10, the system_LPC17xx.c 1.01, and the startup_LPC17xx.s 1.0 are the combination of the files that work. There is either something very wrong with the new files or I am missing something.
Should I use the old files or do any of you know how to make the new ones work?