pwm channel 7 correction, enhanced mode

pull/144/head
0xc0170 2013-12-30 18:12:01 +01:00
parent 8d7c3da179
commit a384d1d875
1 changed files with 11 additions and 11 deletions

View File

@ -22,15 +22,15 @@
static const PinMap PinMap_PWM[] = {
// LEDs
{LED_RED , PWM_3 , 3}, // PTC3, FTM0 CH2
{LED_GREEN, PWM_5, 3}, // PTD4, FTM0 CH4
{LED_BLUE , PWM_9 , 3}, // PTA2 , FTM0 CH7
{LED_GREEN, PWM_5, 3}, // PTD4, FTM0 CH4
{LED_BLUE , PWM_8 , 3}, // PTA2, FTM0 CH7
// Arduino digital pinout
{D3, PWM_5 , 3}, // PTD4, FTM0 CH4
{D5, PWM_7 , 3}, // PTA1 , FTM0 CH6
{D6, PWM_3 , 3}, // PTC3 , FTM0 CH2
{D9, PWM_8 , 4}, // PTD2 , FTM0 CH7
{D10, PWM_2 , 4}, // PTC2 , FTM0 CH1
{D5, PWM_7 , 3}, // PTA1, FTM0 CH6
{D6, PWM_3 , 3}, // PTC3, FTM0 CH2
{D9, PWM_8 , 4}, // PTD2, FTM0 CH7
{D10, PWM_2 , 4}, // PTC2, FTM0 CH1
{NC , NC , 0}
};
@ -54,10 +54,9 @@ void pwmout_init(pwmout_t* obj, PinName pin) {
ftm->MODE |= FTM_MODE_WPDIS_MASK; //write protection disabled
ftm->CONF |= FTM_CONF_BDMMODE(3);
ftm->SC = FTM_SC_CLKS(1) | FTM_SC_PS(6); // (48)MHz / 64 = (0.75)MHz
ftm->PWMLOAD |= FTM_PWMLOAD_LDOK_MASK;
ftm->CONTROLS[ch_n].CnSC = (FTM_CnSC_MSB_MASK | FTM_CnSC_ELSB_MASK); /* No Interrupts; High True pulses on Edge Aligned PWM */
ftm->PWMLOAD |= FTM_PWMLOAD_LDOK_MASK; //loading updated values enabled
//ftm->SYNCONF |= FTM_SYNCONF_SWRSTCNT_MASK;
ftm->MODE |= FTM_MODE_INIT_MASK;
ftm->SYNCONF |= FTM_SYNCONF_SYNCMODE_MASK | FTM_SYNCONF_SWWRBUF_MASK; //enhanced
obj->CnV = &ftm->CONTROLS[ch_n].CnV;
obj->MOD = &ftm->MOD;
@ -66,7 +65,7 @@ void pwmout_init(pwmout_t* obj, PinName pin) {
// default to 20ms: standard for servos, and fine for e.g. brightness control
pwmout_period_ms(obj, 20);
pwmout_write (obj, 0);
pwmout_write(obj, 0);
// Wire pinout
pinmap_pinout(pin, PinMap_PWM);
@ -83,7 +82,7 @@ void pwmout_write(pwmout_t* obj, float value) {
*obj->CnV = (uint32_t)((float)(*obj->MOD) * value);
*obj->CNT = 0;
//*obj->SYNC |= FTM_SYNC_SWSYNC_MASK;
*obj->SYNC |= FTM_SYNC_SWSYNC_MASK;
}
float pwmout_read(pwmout_t* obj) {
@ -116,4 +115,5 @@ void pwmout_pulsewidth_ms(pwmout_t* obj, int ms) {
void pwmout_pulsewidth_us(pwmout_t* obj, int us) {
*obj->CnV = PWM_CLOCK_MHZ * us;
*obj->SYNC |= FTM_SYNC_SWSYNC_MASK;
}