Home arrow Support arrow Forums

Luminary Micro Forums

rbattle

Junior Boarder
Click here to see the profile of this user

2007/01/11 01:08

Interrupt Handlers . . . GOTCHA!

I wasn't able to get my C routine to run as an Interrupt Handler even if I used this driver library routine:
ADCIntRegister(ADC_BASE,3,ADCIntHandler);

When I looked at some of the example programs, the interrupt handlers worked and they didn't use ADCIntRegister(). I realized you need to setup your own vectors in the Startup.s file.

For Example, in my main file:

//*************************************************
//
// The interrupt handler for the ADC interrupt.
//
//*************************************************
void ADCIntHandler(void)
{
unsigned long ulData;

//
// Clear the ADC interrupt.
//
ADCIntClear(ADC_BASE, 3);

//
// Read the data from the ADC sequence 3
//
ADCSequenceDataGet(ADC_BASE, 3, &ulData);

//
// Rest of your code in here
//
}

Now change this in your Startup.s file:

;*************************************************
;
; The vector table.
;
;*************************************************
Vectors


DCD IntDefaultHandler ; ADC Sequence 0
DCD IntDefaultHandler ; ADC Sequence 1
DCD IntDefaultHandler ; ADC Sequence 2
EXTERN ADCIntHandler ; VERY important!
DCD ADCIntHandler ; ADC Sequence 3


Make sure you enable ALL your interrupts and you should be on your way! Hope this helps.
-Ron

login or register to reply

tinroofrusty

Expert Boarder
Click here to see the profile of this user

2007/01/12 00:24

Re:Interrupt Handlers . . . GOTCHA!

This one had me scratching my head also. I only got my board yesterday and giving up on having sprintf work, I wanted a system tick. There is an obscure mention of the issue you raise in the documentation - something about linker scripts not supported on the evaluation tools. After much scrutiny of the demo code, like yourself, I found how to do it. The other thing that confused me initially was no _interrupt declaration on the code like with other arm based micros - until I read the doc on the Cortex that told me the hardware stack/unstacks the cpu regs.

The library doc should have a bit more application code to show the more common uses and mention what header files you should include. Having to go backwards from the demo code is a bit lame.

The use of the ADC is a bit complex - all I want to do is call a routine that returns the current value of an input! Then there's the GPIO configuration - I've never seen so many registers for i/o configuration!

The uart also does not have a 9bit mode. No problem for me, but quite a few apps use this.


That's my opinions after less than 24hours exposure to these micros!

login or register to reply

repatch

Fresh Boarder
Click here to see the profile of this user

2007/01/24 20:44

Re:Interrupt Handlers . . . GOTCHA!

Wow, good there is a forum here!

I also was having trouble with interrupts. Was using UART0, but wanted to switch to UART1. Changed everything I thought I needed too... did work! :(

However, thanks to your pointer I modified startup.s and all is well, thanks for that!

Luminary really should include more example code in their docs, trying to reverse engineer demo code, as you say, is not the best way to do things.

Thanks again. TTYL

login or register to reply