|
Hello all :)
I'm porting a working sound-board application from the sam7S to the sam7X. I also moved from IAR 4.5 to IAR 6.2
The system does the usual i2c to the DAC via the ssc port. This worked fine with the sam7s.
In this sam7x version the problem arises when the PDC-transmit buffer interrupt is enabled, sending the processor to la-la land. Even though the port is setup the same way as in the previous project, with all the proper register header files and #definitions included and double-checked.
I've stripped the code to the very minimum:
#define __inline inline #include "AT91SAM7XC256.h" #include "lib_AT91SAM7X256.h"
int main() { //pll: initclocks(); //Sets PLL = 95.846MHz ; MCK = 47.92MHz. (for CPU, Periphs, & USB) //watchdog: *AT91C_WDTC_WDMR = 0x30FF20FF;//1sec watchdog *AT91C_WDTC_WDCR = 0xA5000001;//Reset watchdog
//init interrupt for PDC-SSC: AT91F_AIC_ConfigureIt (pAic, AT91C_ID_SSC, 6, AT91C_AIC_SRCTYPE_EXT_POSITIVE_EDGE, send_to_DAC);//here we say what function services the interrupt (pointer,interrupt,priority,edge,functionname) *AT91C_AIC_IECR |= 0x100; //Enable PDC SSC(8) interrupts
*AT91C_SSC_IER |= 0x004; //<<<<****THIS LINE IS THE PROBLEM***** Enable PDC-SSC-TxEnd transmission interrupt (triggers when transmit counter reaches zero), Priority 6 (second-highest)
/////MAIN LOOP /////////////////////////////////// for(;;){ //Blink LED i++; if(i==500000) { *AT91C_PIOA_CODR |= 0x10000000;}//Turn LED ON.. (PA28) if(i==1000000){ *AT91C_PIOA_SODR |= 0x10000000; i=0;} //Turn LED OFF.. (PA28) *AT91C_WDTC_WDCR = 0xA5000001;//reset watchdog, } // }
void send_to_DAC(void) { *AT91C_AIC_EOICR=*AT91C_AIC_EOICR;//acknowledge interrupt (interrupt done) to clear flags return; }
Everything works fine, the program reaches the main loop and the LED blinks, until the line that enables the interrupt is uncommented.
It seems that the interrupt flag is set the whole time and the interrupt vector points to the wrong place, even though it was specificaly setup to go to the send_to_DAC() function.
Could this be instead related to those .mac files or startup files that IAR uses in the projects?? To be honest I haven't really fully understood those and how they get linked in your assembly. I guess this is the stage where you blame the compiler for a while...
I've tried recreating the project from one of the example IAR projects and moving-in my code; I've gone through all the project->options (optimizations,linker configuration), etc, but I don't know what could be making the processor freeze or go nuts at that point like that.
Any help would be really appreciated guys, right now I'm just stuck in that line but I've run out of ideas.
I hope one of you has seen this issue before, thanks!
Last edited by volkswagenb on Tue Dec 14, 2010 5:50 pm, edited 1 time in total.
|