timerInit funtion is working to reset a periferal we first need to set the bit to 1 an then to 0 again. need to implement timerSetMode();

interrupts
key 4 years ago
parent 2c2d318217
commit ee0f8227b9

@ -38,7 +38,6 @@ typedef enum {
counter,
inputCapture,
outputCompare,
pwm,
onePulse
} timerMode_t;
@ -55,7 +54,6 @@ uint8_t timerGetUpdateInterrupt(timerNo_t timer);
void timerClearUpdateInterrupt(timerNo_t timer);
void timerClearCounter(timerNo_t timer);
/* Second stage configuration */
void timerInit(timerNo_t timer, uint32_t prescaler, uint32_t period, timerCountDirection_t direction, timerMode_t mode);
void timerSetHz(timerNo_t timer, uint16_t hz);

@ -194,6 +194,15 @@ static const uint8_t timerBus_En_bitPos[MAX_TIMER_CHANNEL_COUNT] = {
RCC_APB2ENR_TIM17EN_Pos
};
static const uint8_t timerBus_Rst_bitPos[MAX_TIMER_CHANNEL_COUNT] = {
RCC_APB2RSTR_TIM1RST_Pos,
RCC_APB1RSTR_TIM2RST_Pos,
RCC_APB1RSTR_TIM3RST_Pos,
RCC_APB1RSTR_TIM14RST_Pos,
RCC_APB2RSTR_TIM16RST_Pos,
RCC_APB2RSTR_TIM17RST_Pos
};
static const uint8_t timerBus_No[MAX_TIMER_CHANNEL_COUNT] = {
2,
1,
@ -203,15 +212,6 @@ static const uint8_t timerBus_No[MAX_TIMER_CHANNEL_COUNT] = {
2
};
static const uint32_t timerMaxCounter[MAX_TIMER_CHANNEL_COUNT] = {
0xFFFF, /*!< Timer 1 has a 16 bit counter */
0xFFFFFFFF, /*!< Timer 2 has a 32 bit counter */
0xFFFF, /*!< Timer 3 has a 16 bit counter */
0xFFFF, /*!< Timer 14 has a 16 bit counter */
0xFFFF, /*!< Timer 16 has a 16 bit counter */
0xFFFF /*!< Timer 17 has a 16 bit counter */
};
#ifdef __cplusplus
}
#endif

@ -5,7 +5,14 @@
void timerReset(timerNo_t timer)
{
// To implement RM page 116
if(timerBus_No[timer]==1)
{
RCC->APB1RSTR |= (1<<timerBus_Rst_bitPos[timer]);
RCC->APB1RSTR &=~ (1<<timerBus_Rst_bitPos[timer]);
return;
}
RCC->APB2RSTR |= (1<<timerBus_Rst_bitPos[timer]);
RCC->APB2RSTR &=~ (1<<timerBus_Rst_bitPos[timer]);
}
void timerActivateBus(timerNo_t timer)
@ -85,7 +92,7 @@ void timerInit( timerNo_t timer,
{
timerActivateBus(timer);
timerReset(timer);
timerSetMode(mode);
timerSetMode(timer, mode);
timerSetCountDirection(timer,direction);
timerSetPrescaler(timer, prescaler);
timerSetAutoReload(timer, period);

@ -17,7 +17,7 @@ int main(int argc, char *argv[])
//timerSetHz(timer_2,3);
timerInit(timer_2, 7999, 999, counter, downCounting);
timerInit(timer_2, 7999, 999, downCounting, counter);
timerSart(timer_2);
pinConfig(pinB3, output, pushPull, def_res, def_speed);

Loading…
Cancel
Save