Skip to content

Commit 8899527

Browse files
committed
PWM - mux addition
1 parent a6e45b7 commit 8899527

File tree

1 file changed

+18
-10
lines changed
  • libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M

1 file changed

+18
-10
lines changed

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D5M/pwmout_api.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,30 @@
2121

2222
static const PinMap PinMap_PWM[] = {
2323
// LEDs
24-
{LED_RED , PWM_3 , 3}, // PTC3, FTM0 CH2
25-
{LED_GREEN, PWM_5, 3}, // PTD4, FTM0 CH4
24+
{LED_RED , PWM_3 , 4}, // PTC3, FTM0 CH2
25+
{LED_GREEN, PWM_5, 4}, // PTD4, FTM0 CH4
2626
{LED_BLUE , PWM_8 , 3}, // PTA2, FTM0 CH7
2727

2828
// Arduino digital pinout
29-
{D3, PWM_5 , 3}, // PTD4, FTM0 CH4
29+
{D3, PWM_5 , 4}, // PTD4, FTM0 CH4
3030
{D5, PWM_7 , 3}, // PTA1, FTM0 CH6
31-
{D6, PWM_3 , 3}, // PTC3, FTM0 CH2
32-
{D9, PWM_8 , 4}, // PTD2, FTM0 CH7
31+
{D6, PWM_3 , 4}, // PTC3, FTM0 CH2
32+
{D9, PWM_6 , 4}, // PTD5, FTM0 CH6
3333
{D10, PWM_2 , 4}, // PTC2, FTM0 CH1
3434

35+
{PTA0, PWM_6 , 3}, // PTA0, FTM0 CH5
36+
{PTA3, PWM_0 , 3}, // PTA3, FTM0 CH0
37+
{PTA4, PWM_1 , 3}, // PTA4, FTM0 CH1
38+
{PTA5, PWM_3 , 3}, // PTA5, FTM0 CH2
39+
{PTA12, PWM_9 , 3}, // PTA12, FTM1 CH0
40+
{PTA13, PWM_10, 3}, // PTA13, FTM1 CH1
41+
{PTB0, PWM_9 , 3}, // PTB0, FTM1 CH0
42+
{PTB1, PWM_10, 3}, // PTB1, FTM1 CH1
43+
{PTC1, PWM_0 , 4}, // PTC1, FTM0 CH0
44+
{PTD4, PWM_4 , 4}, // PTD4, FTM0 CH3
45+
{PTD6, PWM_7 , 4}, // PTD6, FTM0 CH6
46+
{PTD7, PWM_8 , 4}, // PTD7, FTM0 CH7
47+
3548
{NC , NC , 0}
3649
};
3750

@@ -51,15 +64,13 @@ void pwmout_init(pwmout_t* obj, PinName pin) {
5164
SIM->SCGC6 |= 1 << (SIM_SCGC6_FTM0_SHIFT + ftm_n);
5265

5366
FTM_Type *ftm = (FTM_Type *)(FTM0_BASE + 0x1000 * ftm_n);
54-
ftm->MODE |= FTM_MODE_WPDIS_MASK; //write protection disabled
5567
ftm->CONF |= FTM_CONF_BDMMODE(3);
5668
ftm->SC = FTM_SC_CLKS(1) | FTM_SC_PS(6); // (48)MHz / 64 = (0.75)MHz
5769
ftm->CONTROLS[ch_n].CnSC = (FTM_CnSC_MSB_MASK | FTM_CnSC_ELSB_MASK); /* No Interrupts; High True pulses on Edge Aligned PWM */
5870

5971
obj->CnV = &ftm->CONTROLS[ch_n].CnV;
6072
obj->MOD = &ftm->MOD;
6173
obj->CNT = &ftm->CNT;
62-
obj->PWMLOAD = &ftm->PWMLOAD;
6374

6475
// default to 20ms: standard for servos, and fine for e.g. brightness control
6576
pwmout_period_ms(obj, 20);
@@ -79,8 +90,6 @@ void pwmout_write(pwmout_t* obj, float value) {
7990
}
8091

8192
*obj->CnV = (uint32_t)((float)(*obj->MOD) * value);
82-
*obj->PWMLOAD |= FTM_PWMLOAD_LDOK_MASK;
83-
*obj->CNT = 0;
8493
}
8594

8695
float pwmout_read(pwmout_t* obj) {
@@ -113,5 +122,4 @@ void pwmout_pulsewidth_ms(pwmout_t* obj, int ms) {
113122

114123
void pwmout_pulsewidth_us(pwmout_t* obj, int us) {
115124
*obj->CnV = PWM_CLOCK_MHZ * us;
116-
*obj->PWMLOAD |= FTM_PWMLOAD_LDOK_MASK;
117125
}

0 commit comments

Comments
 (0)