| Electronic Components Datasheet Search |
|
AN2618 Datasheet(PDF) 20 Page - STMicroelectronics |
|
|
|||||||||||||||||||||||||||||
AN2618 Datasheet(HTML) 20 Page - STMicroelectronics |
|
20 / 23 page ![]() Code example 7.etpu_pwm.c AN2618 20/23 Appendix G Code example 7.etpu_pwm.c #include "etpu_constants.h" #include "etpu_pwm_auto.h" #define ETPU_PSE_RAM_OFFSET 0x1000 /******************************************************************************** * FUNCTION: etpu_pwm_init * * PURPOSE: This function executes on the host CPU. * * The function checks validity for parameters then pass them to * * the eTPU functions. The function issue the host service request to * * eTPU PWM function to initiate the execution. * ********************************************************************************/ int etpu_pwm_init(unsigned char channel, unsigned long period, unsigned long duty) { int errorCode = 0; unsigned long functFrame = ETPU.CHAN[channel].CR.B.CPBA; unsigned long *pba_32 = &DATA_RAM + (functFrame << 1) + ETPU_PSE_RAM_OFFSET; // function parameter validity check if (period > 0xFFFFFF) { errorCode = PARAM_OUT_RANGE; period = 0xFFFFFF; } if (duty > 0xFFFFFF) { errorCode = PARAM_OUT_RANGE; duty = 0xFFFFFF; } // passing function parameter to eTPU function frame *(pba_32 + ETPU_PWM_PERIOD_OFFSET) = period; *(pba_32 + ETPU_PWM_DUTY_OFFSET) = duty; //write hsr ETPU.CHAN[channel].HSRR.R = ETPU_PWM_INIT; return (errorCode); } /******************************************************************************** * FUNCTION: etpu_pwm_update * * PURPOSE: This function executes on the host CPU. * * This function checks validity for parameters then pass them to * * the eTPU functions. The function issue the host service request to * * eTPU PWM function to update the function parameters. * ********************************************************************************/ int etpu_pwm_update(unsigned char channel, unsigned long period, unsigned long duty) { int errorCode = 0; unsigned long functFrame = ETPU.CHAN[channel].CR.B.CPBA; unsigned long *pba_32 = &DATA_RAM + (functFrame << 1) + ETPU_PSE_RAM_OFFSET; // function parameter validity check if (period > 0xFFFFFF) { errorCode = PARAM_OUT_RANGE; period = 0xFFFFFF; |
|
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |