尊敬的恩智浦的各位工程师和朋友:我现在在学习s32k324,目前我想了解这个芯片pwm的具体实现方法和效果,请问是否有s32k324系列的pwm教程手册,另外我有一个pwm的例程看不懂,有相关的解释吗?谢谢!
(相关主函数代码
int main(void)
{
uint8 num_blink = 0U;
/* Initialize the Mcu driver */
Mcu_Init(&Mcu_Config_VS_0);
/* Initialize the clock tree */
Mcu_InitClock(McuClockSettingConfig_0);
/* Apply a mode configuration */
Mcu_SetMode(McuModeSettingConf_0);
/* Initialize all pins using the Port driver */
Port_Init(&Port_Config_VS_0);
/* Initialize Mcl driver */
Mcl_Init(&Mcl_Config_VS_0);
/* Initialize Pwm driver , after that Led on*/
Pwm_Init(&Pwm_Config_VS_0);
/* Set new period for all channels used external counter bus */
Mcl_Emios_SetCounterBusPeriod(MCL_EMIOS_1_CH_23, 0x9000U, FALSE);
Mcl_Emios_SetCounterBusPeriod(MCL_EMIOS_0_CH_22, 0x9000U, FALSE);
/* Decreasing LED brightness using Pwm_SetDutyCycle*/
Pwm_SetDutyCycle(PwmChannel_0, 0x200);
/* Setup new duty cycle to the pin*/
Pwm_SetDutyCycle(PwmChannel_1, 0x200);
/* Increasing LED brightness using Pwm_SetDutyCycle*/
Pwm_SetDutyCycle(PwmChannel_0, 0x4000);
/* Setup new duty cycle to the pin*/
Pwm_SetDutyCycle(PwmChannel_1, 0x4000);
/* Using duty cycle 0% and 100% to Blink LED */
while(num_blink < NUM_BLINK_LED)
{
/* Led on when duty cycle is 100% */
Pwm_SetDutyCycle(PwmChannel_0, 0x8000);
TestDelay(DELAY_TIMER);
/* Led off when duty cycle is 0% */
Pwm_SetDutyCycle(PwmChannel_0, 0x0000);
TestDelay(DELAY_TIMER);
num_blink++;
}
/* De-Initialize Pwm driver */
Pwm_DeInit();
return 0U;
}
)
Hi,
the eMIOS module is used for PWM signal generation, so please refer to eMIOS chapter (Chapter 64
Enhanced Modular IO Subsystem (eMIOS)) of the device Reference manual for more info about eMIOS functionality.
The code you shared looks as RTD demo code, which should run fine, or did you change setting in config tools anyhow? Note this code generate signal for some time then deinit module.
BR, Petr
谢谢您的回复,代码确实可以正常运行,但是我似乎看不到开发板的实验现象,据描述,他应该会使led发生状态变化,但实际上运行过程中开发板的灯始终是灭的
Hi,
I tried pwm_example_S32K344 from S32DS3.5 with RTD300. Created new project, updated code in config tool, built and run a code on S32k3x4EVB.
RED LED (PwmCHannle_0) is blinking 10times in cca 1sec rate. You can also step the code to see LED brightness change first.
BR, Petr
Thanks for sharing, but there seems to be a new problem when I am debugging, the error message is
WARNING: Failed to read memory @ address 0x2001FFC0
WARNING: Failed to read memory @ address 0x2001FFF8
I thought it was a problem with the burner, but I did not get this error when I tested other examples. Could you please tell me what went wrong? Thank you very much