PWM registers of timers problem APB1 and alternative function NUCLEOF303RE
Hi,
I'm encountering several issues with my timers. Firstly, my timers, specifically Timer3 which is connected to APB1, aren't functioning as expected. I've also attempted to use Timer16, which operates on a clock derived from another peripheral communication bus. However, the main issue seems to be with the RCC clock for my communication bus, as it doesn't appear to be functioning properly.
I've verified the functionality of Timer3 by testing it with an external interrupt handler, but it still doesn't seem to be working correctly. Additionally, I've implemented PWM (Pulse Width Modulation) functionality, but it hasn't yielded the expected results.
Furthermore, I'm encountering difficulties with configuring alternate functions. Specifically, I'm struggling to set the appropriate bits in the AFR (Alternate Function Register).
I would greatly appreciate any assistance or guidance as I strive to become proficient in embedded programming.
void configPWMPA6(void)
{
RCC -> AHBENR |= RCC_AHBENR_GPIOAEN;
//GPIOA -> MODER |= GPIO_MODER_MODER6_1;
GPIOA -> MODER &= ~(GPIO_MODER_MODER6_0);
GPIOA -> MODER |= GPIO_MODER_MODER6_1;
GPIOA -> AFR[0] |= GPIO_AFRL_AFRL6_0; //Not working Reset value 0x00000
//GPIOA -> AFR[0] &= ~(GPIO_AFRL_AFRL6_Msk);
GPIOA -> AFR[0] |= (1<<24);
}
#include "stm32f303xe.h"
#include "stdint.h"
#include "stm32f3xx.h"
void TIM3_BaseCONFIGURATION(void)
{
RCC -> APB1ENR |= RCC_APB1ENR_TIM3EN;
TIM3-> PSC = 36;
TIM3-> ARR = 100;
}
void TIM3_START(void)
{
TIM3-> CNT =0;
TIM3-> CR1 |= TIM_CR1_CEN;
}
void TIMER_UPDATE(void)
{
TIM3-> DIER |= TIM_DIER_UIE;
NVIC_SetPriority(TIM3_IRQn,0);
NVIC_EnableIRQ(TIM3_IRQn);
}
void TIM3_HANDLER(void)
{
if(TIM3->SR & TIM_SR_UIF)
{
TIM3->SR &= ~(TIM_SR_UIF);
}
}
//PC13 Button
//0 push /1 set
//PA2_TX
//PA3_RX
//AF7 0111
// 115200
//36 000 000 prescaler 2??? MAX ABH1=F
int main(void)
{
SysTick_Config((72000000/ 1000));
TIM3_BaseCONFIGURATION();
TIMER_UPDATE();
TIM3_START();
//1s = 72 000 000
// 0,001 = x
/* Loop forever */
while(1)
{
}
}
