21
21
22
22
static const PinMap PinMap_PWM [] = {
23
23
// 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
26
26
{LED_BLUE , PWM_8 , 3 }, // PTA2, FTM0 CH7
27
27
28
28
// Arduino digital pinout
29
- {D3 , PWM_5 , 3 }, // PTD4, FTM0 CH4
29
+ {D3 , PWM_5 , 4 }, // PTD4, FTM0 CH4
30
30
{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
33
33
{D10 , PWM_2 , 4 }, // PTC2, FTM0 CH1
34
34
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
+
35
48
{NC , NC , 0 }
36
49
};
37
50
@@ -51,15 +64,13 @@ void pwmout_init(pwmout_t* obj, PinName pin) {
51
64
SIM -> SCGC6 |= 1 << (SIM_SCGC6_FTM0_SHIFT + ftm_n );
52
65
53
66
FTM_Type * ftm = (FTM_Type * )(FTM0_BASE + 0x1000 * ftm_n );
54
- ftm -> MODE |= FTM_MODE_WPDIS_MASK ; //write protection disabled
55
67
ftm -> CONF |= FTM_CONF_BDMMODE (3 );
56
68
ftm -> SC = FTM_SC_CLKS (1 ) | FTM_SC_PS (6 ); // (48)MHz / 64 = (0.75)MHz
57
69
ftm -> CONTROLS [ch_n ].CnSC = (FTM_CnSC_MSB_MASK | FTM_CnSC_ELSB_MASK ); /* No Interrupts; High True pulses on Edge Aligned PWM */
58
70
59
71
obj -> CnV = & ftm -> CONTROLS [ch_n ].CnV ;
60
72
obj -> MOD = & ftm -> MOD ;
61
73
obj -> CNT = & ftm -> CNT ;
62
- obj -> PWMLOAD = & ftm -> PWMLOAD ;
63
74
64
75
// default to 20ms: standard for servos, and fine for e.g. brightness control
65
76
pwmout_period_ms (obj , 20 );
@@ -79,8 +90,6 @@ void pwmout_write(pwmout_t* obj, float value) {
79
90
}
80
91
81
92
* obj -> CnV = (uint32_t )((float )(* obj -> MOD ) * value );
82
- * obj -> PWMLOAD |= FTM_PWMLOAD_LDOK_MASK ;
83
- * obj -> CNT = 0 ;
84
93
}
85
94
86
95
float pwmout_read (pwmout_t * obj ) {
@@ -113,5 +122,4 @@ void pwmout_pulsewidth_ms(pwmout_t* obj, int ms) {
113
122
114
123
void pwmout_pulsewidth_us (pwmout_t * obj , int us ) {
115
124
* obj -> CnV = PWM_CLOCK_MHZ * us ;
116
- * obj -> PWMLOAD |= FTM_PWMLOAD_LDOK_MASK ;
117
125
}
0 commit comments