Hi ! Im new to STM and have to write a 180 Degree conduction code using CUBE IDE need help Im also attaching a code that I wrote for Tiva. Please help out
Could use any pins available in STM
STM Board : STM32F407VGT6 MCU Discovery board
#include "TM4C123.h"
int count;
void TIMER_INITIALISE(void);
int main(void){
count = 0;
SYSCTL->RCGCGPIO |= (1<<1); // ENABLE SYSTEM CLOCK TO PORT B /
GPIOB->DEN |= (1<<0) | (1<<1) | (1<<2) | (1<<3) | (1<<4) | (1<<5) | (1<<6);
GPIOB->DIR |= (1<<0) | (1<<1) | (1<<2) | (1<<3) | (1<<4) | (1<<5) | (1<<6);
TIMER_INITIALISE();
while(1){
}
}
void TIMER1A_Handler(){
if (count == 0){
GPIOB->DATA |= (1<<0) | (1<<4) | (1<<5);
GPIOB->DATA &= (~(1<<1)) & (~(1<<2)) & (~(1<<3)) ;
TIMER1->ICR |= (1<<0);
}
else if (count == 17){
GPIOB->DATA |= (1<<0) | (1<<1) | (1<<5);
GPIOB->DATA &= (~(1<<2)) & (~(1<<3)) & (~(1<<4)) ;
TIMER1->ICR |= (1<<0);
}
else if (count == 34){
GPIOB->DATA |= (1<<0) | (1<<1) | (1<<2);
GPIOB->DATA &= (~(1<<3)) & (~(1<<4)) & (~(1<<5)) ;
TIMER1->ICR |= (1<<0);
}
else if (count == 51){
GPIOB->DATA |= (1<<1) | (1<<2) | (1<<3);
GPIOB->DATA &= (~(1<<0)) & (~(1<<4)) & (~(1<<5)) ;
TIMER1->ICR |= (1<<0);
}
else if (count == 68){
GPIOB->DATA |= (1<<2) | (1<<3) | (1<<4);
GPIOB->DATA &= (~(1<<0)) & (~(1<<1)) & (~(1<<5)) ;
TIMER1->ICR |= (1<<0);
}
else if (count == 85){
GPIOB->DATA |= (1<<3) | (1<<4) | (1<<5);
GPIOB->DATA &= (~(1<<0)) & (~(1<<1)) & (~(1<<2)) ;
TIMER1->ICR |= (1<<0);
}
count++;
if (count == 101){
count = 0;
}
}
// TIMERS
void TIMER_INITIALISE(){
SYSCTL->RCGCTIMER |= (1<<1);
TIMER1->CTL &= (~(1<<0));
TIMER1->CFG = 0x0;
TIMER1->TAMR = 0x2;
TIMER1->TAILR = 53000;
TIMER1->ICR |= (1<<0);
TIMER1->IMR |= (1<<0);
TIMER1->CTL |= (1<<0);
NVIC->ISER[0] |= (1<<21);
}