關於dsPIC33EP256MC506使用MCC產出的程式問題

作者 DengKai 於 2018年04月02日 16:08:42
今天要使用dsPIC33EP256MC506的PWM功能時,利用MCC產出程式後發現在pwm.h中所提供的一個功能函式有錯誤。
這個功能函式是要設定IOCONx暫存器中的OVRDAT<1:0>的值,紅色的部分應該要改成overrideData & 0x0003,分享給大家~

/**
@Summary
Updates PWM override data bits with the requested value for a specific instance.

@Description
This routine is used to updates PWM override data bits with the requested value for a specific instance.

@Param
genNum - PWM generator instance number.
overrideData - Override data

@Returns
None

@Example
<code>
PWM_GENERATOR genNum;
uint16_t overrideData;

overrideData = 0x01;

genNum = PWM_GENERATOR_1;
PWM_OverrideDataSet(genNum, overrideData);
</code>
*/
inline static void PWM_OverrideDataSet(PWM_GENERATOR genNum,uint16_t overrideData)
{
switch(genNum) {
case PWM_GENERATOR_1:
overrideData = ((overrideData & 0xFFFC)<<6);
__builtin_write_PWMSFR(&IOCON1, (IOCON1 | overrideData), &PWMKEY);
break;
case PWM_GENERATOR_2:
overrideData = ((overrideData & 0xFFFC)<<6);
__builtin_write_PWMSFR(&IOCON2, (IOCON2 | overrideData), &PWMKEY);
break;
case PWM_GENERATOR_3:
overrideData = ((overrideData & 0xFFFC)<<6);
__builtin_write_PWMSFR(&IOCON3, (IOCON3 | overrideData), &PWMKEY);
break;
default:break;
}
}

附加檔案:



jpg  register.jpg (209.43 KB)
49644_5ac1e56405c99.jpg 805X842 px

jpg  code.jpg (92.38 KB)
49644_5ac1e56c85ad0.jpg 659X733 px

來自: http://www.microchip.com.tw/newbb/viewtopic.php?forum=2&topic_id=22250&post_id=77937