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
What do you think happen when you do:
priority = 1; src_type = 0x01;
and then:
AT91F_AIC_ConfigureIt(pAic, irq_id, priority,src_type, ST_interrupt);
Think about the line:
pAic->AIC_SMR[irq_id] = src_type | priority ;
With src_type = 1 and priority = 1, what use do you think that or operation makes? Are you spending any time trying to understand the answers you receive? What does the data sheet say about initializing the AIC_SMR register with the value 1?
The priority level can be between 0 (lowest) and 7 (highest).
so I select the value 1 for the priority - I don't see any disadvantages about it.
SCR_TYPE 0 0 high-level sensitive 0 1 positive edge-triggerd (is this not right to use this mode)?
0 1 are the bits 5 and 6 so it's 0x0000 0001 or not?
Or is this configuration false for the ST timer?
johannes
Very wrong. Look again at the data sheet. You are trying to store source type and priority in the same bits. Obviously that does not work. Have you read the data sheet? They normally very clearly shows what data is stored in the different bits of a register.
Also, Christoph Franck have already written in an earlier post what values you may use for the source type. I can't see how you can manage to call the least significant bit "bit 5" or "bit 6".
You just posted the piece of code that provides the answer to the question:
There is nothing in here that shifts src_type 5 bit positions to the left, is there ?
Also, you may want to work with the #define constants in the #include file instead of numeric values:
#define AT91C_AIC_SRCTYPE (0x3 << 5) // (AIC) Interrupt Source Type #define AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE (0x0 << 5) // (AIC) Internal Sources Code Label Level Sensitive #define AT91C_AIC_SRCTYPE_INT_EDGE_TRIGGERED (0x1 << 5) // (AIC) Internal Sources Code Label Edge triggered #define AT91C_AIC_SRCTYPE_EXT_HIGH_LEVEL (0x2 << 5) // (AIC) External Sources Code Label High-level Sensitive #define AT91C_AIC_SRCTYPE_EXT_POSITIVE_EDGE (0x3 << 5) // (AIC) External Sources Code Label Positive Edge triggered