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.

PWM interrupt doesn't come through

Other Parts Discussed in Thread: HALCOGEN

Hi again

I'm making good progress learning the RM4 environment. Now I'm strugling with interrupts.

I used HalCoGen to configure a PWM (using the blackbox driver of HalCoGen). The PWM works fine.

Now I want to generate an interrupt synchronous with the PWM. I found a thread in this forum describing the steps needed to generate interrupts.

I think I did them all, but the interrupt routine is not called. So I probably miss something. But what?

These are the things I do:

(I'm using PWM0 of HET1)

- In HalCoGen connecting the ''End Of Period'' event of PWM0 to the High Level interrupt

- Enabling interrupt 10 (Het High) to the FIQ

- In my main() routine calling hetInit(); and pwmEnableNotification(hetREG1,pwm0,pwmEND_OF_PERIOD); (both found in het.c)

- In the main() routine calling HW_Vec_Init(); to enable the vector interrupts of the processor

The HW_Vec_Init(); function is an assembly routine with the following contents:

    .global HW_Vec_Init

HW_Vec_Init
    stmfd sp!,{r1,LR}
    MRC p15 ,#0 ,R1 ,c1 ,c0 ,#0
    ORR R1 ,R1 ,#0x01000000     ;mask 0-31 bits except bit 24 in Sys Ctrl Reg of CORTEX-R4
    MCR p15 ,#0 ,R1 ,c1 ,c0 ,#0   ;enable bit 24
    ldmfd sp!,{r1,PC}

When I run the application, the PWM is started, but the het1HighLevelInterrupt(); routine in het.c is never called!

So what do I miss here?

Do I have to call other routines generated by HalCoGen ?

I attached my project.

5342.myHetAndPotmeter.zip

  • Cor,

    I have passed your question to the Halcogen team. They will get back to you.

    Thanks and regards,

    Zhaohong

  • Hi Cor,

    Please do the following

    Step 1) .. Enable the HET Interrupt in VIM ( Channel 10).. Follow the Image below.

    Step 2) ..Add " _enable_IRQ(); "  in the main file, This enables IRW bit in the CPSR.

    **********************************

    void main(void)

    {

    /* USER CODE BEGIN (3) */
    unsigned int val;
    unsigned int *ram1;
    int encVal;

    _enable_IRQ();

    muxInit();
    hetInit();
    adcInit();
    gioInit();

    **********************************

    Step 3) ..Go to notification.c and remove "while(1)" in following API's.. I would recommend you to have your own notification file, and do not use notification.c from HALCoGen. This will avoid recreation of while(1) in the notification file.. which you would have commented / removed. 

    void pwmNotification(hetBASE_t * hetREG,uint32_t pwm, uint32_t notification)
    void edgeNotification(hetBASE_t * hetREG,uint32_t edge)
    void hetNotification(hetBASE_t *het, uint32_t offset)

  • Thanks,

    I will be able to try this later today.

    I want to use fast interrupt. So I connected the VIM channel 10 to the FIQ. I assume that is possible too?

    Does there also exist an _enable_FIQ(); routine? Where are these routines defined? I can not find them. Do I need to enable something in HalCoGen so they are generated?

  • It works.

    Thanks.

    (though I still do not undestand where the _enable_IRQ() and _enable_FIQ() are)

  • see help in HAL code generator ,you will find what you want