Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: ssc pdc interrupt enable freezes Sam7X *Solved*
PostPosted: Sat Dec 04, 2010 10:34 pm 
Offline

Joined: Mon Aug 14, 2006 6:10 pm
Posts: 8
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.

Top
 Profile  
 
 Post subject: Re: ssc pdc interrupt enable freezes Sam7X
PostPosted: Sun Dec 05, 2010 4:04 am 
Offline

Joined: Sat Oct 30, 2010 6:04 pm
Posts: 574
The ARM7 doesn't use the AIC and it's "vectors" you specify unless your startup code and ARM vectors (IRQ, FIQ) point at the AIC vectoring address.

LDR PC,[PC,#-0xF20] ; Vector From AIC_IVR

You could use the JTAG debugger in IAR, an disassemble the IRQ/FIQ vectors to confirm they are built as you expect, and breakpoint them or the interrupt handler code to verify things are operating as expected.


Top
 Profile  
 
 Post subject: Re: ssc pdc interrupt enable freezes Sam7X
PostPosted: Mon Dec 06, 2010 4:43 pm 
Offline

Joined: Mon Aug 14, 2006 6:10 pm
Posts: 8
Thanks for your reply CptTitanic,

Funny thing is, the same code under the sam7S worked perfectly, Or rather, under IAR 4.5 ...
by setting the AIC, specifically that's how you setup the vector to point to the interrupt handling function you specify.

Now, I tried to re-compile the old code for the old board, but under IAR 6.2; and it won't even work either anymore; same thing, the pdc-ssc interrupt-enabling sends it into orbit.

The thing is that the IAR 6.2 installation pretty much broke my old project and It won't open under IAR 4.5 anymore.

Anyhow, this really seems to me compiler-related, but I don't know what else to tweak.

I'll try to look for what you suggested:
LDR PC,[PC,#-0xF20] ; Vector From AIC_IVR

I'll also try to move on and work on the other parts that need porting to the sam7X board for now (the spi to the sd card, the usart communication, etc) until some other idea comes to mind.

thanks again,
anyone else has some thoughts on this?


Top
 Profile  
 
 Post subject: Solved
PostPosted: Tue Dec 14, 2010 5:49 pm 
Offline

Joined: Mon Aug 14, 2006 6:10 pm
Posts: 8
OK, I finally passed the 'blame the compiler' stage and 'solved' this thing, the project is finished. pardon my ignorance here.. >:s

This is what I did:

-(1)
I did the thing where the default and spurious interrupt handlers let the pc continue, as
opposed to just being stuck in an infinite loop (the IAR default behaviour for this).

On board_low_level.c file:

void defaultSpuriousHandler( void )
{ // Acknowledge the broken interrupt
*AT91C_AIC_EOICR = *AT91C_AIC_EOICR;
// Return nothing so we move on with life
return;
//while (1); //<<took this out
}


-(2)
The 'paic' pointer that's used in conjunction with the AIC_configure_it function was not being assigned the proper base addres of the AIC. How this worked in the old project is beyond me..
now that looks like:


AT91PS_AIC pAic; //create pointer
...

pAic= AT91C_BASE_AIC; //&0xFFFFF000; //<<DUH! ADDED THIS line for samx version. Somehow it wasn't needed for the sam7s...
AT91F_AIC_ConfigureIt (pAic, AT91C_ID_SSC, 6, AT91C_AIC_SRCTYPE_EXT_POSITIVE_EDGE, send_to_DAC);


-(3)
Also, it seems that on the sam7x the PDC end-of-Transfer interrupts are permanently flagged as long as the TCR transfer counter register is zero, not just when the number reaches zero, as I'm pretty sure was the case with the sam7s.
So the interrupt does happen immediately as soon as you enable it. You just have to make sure it's disabled until actually needed, and that your vectors point to the right place (see point 2 above!!).
This affected both my SSC and UART operations, but it was easily taken care of (worked around) once i figured this out.
I could not for the life of me NOT trigger the interrupt when TCR=0. Maybe some one else here knows if i missed something.


Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: