This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ST timer problems

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

Parents
  • AT91F_AIC_ConfigureIt(pAic, irq_id, priority, src_type, ST_interrupt);
    

    src_type and priority don't have any values assigned to them !

    I'm pretty sure that the compiler is issuing warnings about variables being used before having been assigned a value here. Compiler warnings are there for a reason and usually indicate that there is a problem with your code.

    void ST_interrupt(void)
    {
       AT91C_BASE_AIC->AIC_IDCR = 0xFFFFFFFF;                                    //disable all interrupts
       AT91C_BASE_AIC->AIC_ICCR = 0x00000001;
    

    This is unnecessary and useless at best. Since you probably want the ST interrupt to be level-sensitive, the AIC_ICCR will have no effect. The interrupt will be cleared by reading ST_SR instead.

Reply
  • AT91F_AIC_ConfigureIt(pAic, irq_id, priority, src_type, ST_interrupt);
    

    src_type and priority don't have any values assigned to them !

    I'm pretty sure that the compiler is issuing warnings about variables being used before having been assigned a value here. Compiler warnings are there for a reason and usually indicate that there is a problem with your code.

    void ST_interrupt(void)
    {
       AT91C_BASE_AIC->AIC_IDCR = 0xFFFFFFFF;                                    //disable all interrupts
       AT91C_BASE_AIC->AIC_ICCR = 0x00000001;
    

    This is unnecessary and useless at best. Since you probably want the ST interrupt to be level-sensitive, the AIC_ICCR will have no effect. The interrupt will be cleared by reading ST_SR instead.

Children
No data