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.

Issue with PWM generation

Other Parts Discussed in Thread: HALCOGEN

Hi,

Question related to the PWM generation. Please find the het.c file attached (generated by HALCOGEN). Intention is to modify the period of the PWM waveform in runtime.

Have set the duty cycle and Period initially and the PWM is being generated. After processing for some time , tried to modify the period of it. PWM generation is stopped at this point.

 

Used the below APIs to set the period. 

 

pwmStop (hetRAM1, pwm0);

pwmSetSignal (hetRAM1, pwm0, SignalInfo);

pwmStart (hetRAM1, pwm0);

 

Are we allowed to set the period in normal run mode or do we need to be in privieleged mode to set this ?

Please suggest.

Thanks

2772.het.c

 

 

  • Phil,

    Are you setting SignalInfo with valid data?
    I did a quick project with 1 PWM and I'm able to change the duty cycle or period using the pwmSetSignal (hetRAM1, pwm5, SignalInfo);

    Here is the code that I'm using.
    I'm using an RTI interrupt to change every 50ms the duty cycle from 1 to 100%.


    void rtiNotification(uint32 notification)
    {
    /*  enter user code between the USER CODE BEGIN and USER CODE END. */
    /* USER CODE BEGIN (9) */
        /*  enter user code between the USER CODE BEGIN and USER CODE END. */
            /* Toggle HET pin 0 */
            gioSetPort(hetPORT1, gioGetPort(hetPORT1) ^ 0x00000001);
            if (SignalInfo.duty==100)
            {
                SignalInfo.duty=1;
            }
            else
            {
                SignalInfo.duty++;
            }
    //        pwmStop (hetRAM1, pwm5);
            pwmSetSignal (hetRAM1, pwm5, SignalInfo);
    //        pwmStart (hetRAM1, pwm5);

    /* USER CODE END */
    }

    There is no need to stop and start the PWM in order to change it's parameters. (Unless this is a requirement in your application)

    Remember that the period value is in us. The default period is defined in Halcogen as 1ms

    There is no need to be in privilege mode to change the HET_RAM contents.

  • Hi Philippe,
    Thanks for posting on behalf of me. Actually I found the issue in the mean time but couldn't post you. Sorry for that.

    Hello Jean-Marc,
    Thanks for your reply. The issue I found is that, when I capture a signal the duty value I read in the SignalInfo structure was not correct (It was 0, instead of 50). So when I load the same structure with some period value change, It is not generating a PWM.
    I found that there is some HR Structure sharing stuff to be taken care of while selecting the pins.

    Regards,
    Sai