Hello,
Could you help to install the ST timer on the AT91Rm9200? I don't know how to setup the AIC registers correct. Maybe there are more than one big mistake.
void initialize_pit() { unsigned int flag, period, irq_id, mask, oldHandler, src_type, priority; volatile int status; void *newHandler; //period Timer0->ST_PIMR = period << 5; AT91F_ST_SetPeriodInterval(Timer0, period); //state //status = Timer0->ST_SR; //enable interrupt flag=1; Timer0->ST_IER = flag; AT91F_ST_EnableIt( Timer0, flag); //enable PMC AT91F_PMC_EnablePeriphClock(AT91C_BASE_PMC, 1 << AT91C_ID_IRQ0); //config AIC irq_id = 0; oldHandler = pAic->AIC_SVR[irq_id]; mask = 0x1 << irq_id; pAic->AIC_IDCR = mask ; pAic->AIC_SVR[irq_id] = (unsigned int) newHandler ; //* Store the Source Mode Register pAic->AIC_SMR[irq_id] = src_type | priority ; AT91F_AIC_ConfigureIt(pAic, irq_id, priority, src_type, newHandler); //enable AIC AT91F_AIC_EnableIt(pAic, 1); }
I hope somebody could help me with this problem...
best regards johannes
How can I calculate the storage I need for the interrupts I programm?
That depends on many factors - but the most important are the number of local variables that your ISRs use (they shouldn't use all that many if you stick with the KISS guideline) and whether you allow nesting of ISRs (i.e. one higher-priority ISR can interrupt lower-priority ISRs).
e.g. in the code above; it's a irq interrupt (IRQ_Stack_Size). Why is the USR_Stack_Size so big and when will I use this mode?
USR_Stack_Size is the stack size available in USER mode - which is basically all of your program except for ISRs (FIQ/IRQ), operating-system like parts (SVC), and handlers for specific errors (ABT/UND). You will find more about processor modes in the datasheet, on page 36, in the ARM920T Technical Reference Manual, and the ARM9TDMI Technical Reference Manual (which you should all have a copy of, and read, if you want to do any serious development on that chip).