This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

PGA970: SYST_Handler

Part Number: PGA970

Hi Scott,
Im trying to optimize my code by lowering the CPU load. I thought of using the internal Timer which was provided in your old version PGA970 1.5.
I realized that in startup_ccs.c the M0 System timer handler is beeing refferenced to. Hoping that these mention are responisble for calling the handler i replaced this line (out of the latest version)
   IntDefaultHandler,                       // The M0 System timer handler
with the following code of the 1.5 release

#if (SYST_TESTING == 1)
   SYST_Handler,                           // The M0 System timer handler
#else
   IntDefaultHandler,                      // The M0 System timer handler
#endif

Also I implemented a new pga970_syst.c and pga970_syst.h and included the .h file. Also i enabled SYST_TESTING in the pga970_switch.h file. From now on every command in the syst.c file should be working

Normally you could use this command for example: SYST_Config(0x0000FFFF,0x00000007); which sets a reload value and enables the clock. The CVR register now counts down from the reload value to zero. Hitting zero sets the 16th bit in SYST_CSR (the countflag bit) and resets to the determined reload value. Aditionally the CSR countflag bit gets reset everytime it is accesed. All of the described works as intended. Now to my Question:

My goal is that whenever the countflag is set in the CSR the defined interrupt SYST_Handler shall be called. However if I understood all the datasheets correctly that should be the case with all the things I did. Calling the SYST_Handler manually into my main works fine but it just doesnt get triggered and the Countflagbit remains set meaning there seems to be some kind of trigger missing which should react to the countflag bit.

Regards,
Paul

  • Hi Paul,

    There may be another place where the SYST interrupt needs to be enabled. I will have to look into this. It is likely in the adc config file.

    Regards,

    Scott

  • Hi Scott,
    i made a programm in purpose of investigation:

    //main program
    void main(void)
    {
       __set_PRIMASK(0);
       __set_FAULTMASK(0);
       __set_PRIMASK(0);
       SYST_Config(0x0000001F,0x00000007);
       int count=0;
       while(1)
       {
           count++;
       }
    }

    //--------------------------------------startup_ccs.c file---------------------------------------------
    int intcount=0;

    static void IntDefaultHandler(void)
    {
           intcount++;
    }

    //---------------------------------------pga970_syst.c-----------------------------------------------
    int SYSTcounter=0;
    interrupt void SYST_Handler(void)
    {
       /* Disable System tick  counter */
       SYST_CSR &= ~ST_ENABLE;

       /* Add code here */
       SYSTcounter++;

       /* Enable System tick  counter */
       SYST_CSR |= ST_ENABLE;
    }
    #endif /* SYST_TESTING */

    I enabled the header files and ran the programm without any errors. It has to be run using the "step into" (F5) function in order to see the value of count.
    I was hoping that the program wrongly executed the IntDefaultHandler isntead of the SYST_Handler which doesnt seem to be the case. The count value continues on increasing while the Countflag of SYST_CSR is set. Both of the remaining counting variables remain at zero.
    I would guess that there is something wrong with the NVIC but to be honest i dont really have a clue right now. Did you achieve any results by now?
    regards,
    Paul

  • Hello Scott,
    I figured out that I need some case of "Wait for interrupt" or "sleep" for my project is there something like this implemented?

    However I still was not able to call the SYST_Handler function automaitcally through the exception. I added the codeline "Interrupt_Config()" to my code above since this was necesary for the exceptions to work. Now I was able to recieve  the value 001111--> F --> 15 in the xPSR register for exception, which should mean that the Syst_Handler is to be executed which still isnt the case.

    regards,
    Paul

  • Hi Scott,
    Contacting the ARM support i found the ICSR register which is called NVIC_INT_CTRL with the pga970 it has value of 67108879 --> 100000000000000000000001111.

    Assuming that the bits 27-31 are 0, it seems like that the SYSTick exception is the only exception pending, but the ISR pending flag is not set so no interrupt will be executed. how do i fix that?
    I didnt hear from you for a while now, are you still working on something?

    Regards,
    Paul

  • Hi Paul,

    So to summarize, the SYST_Handler function is never being called, even though the exception occurs (which you confirmed from the NVIC_INT_CTRL register) and should trigger the interrupt service routine? Are you certain that the interrupt is not being masked somehow through one of the other interrupt control registers?

    Regards,
    Scott

  • Hi Scott,
    Yes exactly. No Im not certain that the interrupt is not being masked, how do I check that?

    Regards,Paul

  • Hi Paul,

    You would have make sure that the interrupt is actually being enabled. As another question, what are all of the interrupts that you currently have enabled?

    Regards,

    Scott

  • Hi Scott,
    for enabling the interrupt im using this function:

    void Interrupt_Config(void)
    {
       /* Clear interrupt pending register */
       NVIC_UNPEND0 = 0xFFFFFFFF;
    
       /* Set priority of NVIC interrupt */
       NVIC_PRI0 = 0x80400000;
       NVIC_PRI1 = 0xC0C0C0C0;
    
       /*
        * Enable NVIC interrupts
        * NVIC interrupt for external interrupt 1 i.e. TADC is disabled
        */
       NVIC_ENABLE0 = 0xFFFFFFFD;
    }

    If I understood this code right, the SysTick interrupt should be enabled.  But  so would be all other interrupts so i guess there is my mistake somewhere.Also I set PRIMASK to Zero. I Do not need any other interrupts than SysTick but I do not know how to enable/disable seperate interrupts yet.

    Regards,
    Paul