AnsweredAssumed Answered

Problem for compiling my binary file : source code errors ?

Question asked by charley lanneluc on Oct 24, 2017

Hello everybody,

 

I am new here and i'm just using a STM32F411RE, as a hobby today, but I have encountered a problem with compilation of my binary file. It is just not working and I am trying to figure it out for many days now so I'm hoping that you will give me some advice ! 

 

I have the following code, just to light up the led user in order to understand the process of registers, clocks, interrupts etc...

 

https://os.mbed.com/compiler/#nav:/Essai_Led/stm32; 

 

#include "stm32f4xx.h"
#include "system_stm32f4xx.h"

void SystemInit(void) ; /* Initialization of the system with this file */

int main() {

 

/* Configuration en sortie push pull de la pin 1 */

RCC->AHB1ENR = RCC->AHB1ENR | 0x00000001 ; /* Autorisation de l'horloge des périphériques */
GPIOA->MODER = GPIOA->MODER | 0x00000400 ; /* mise à 01 des bits en outpout du port LED (1 ici ) */
GPIOA->OTYPER = GPIOA->OTYPER | 0xFFFFFFBF ; /* mise à 0 du bit du registre pour output push pull */

/* Configuration du timer */
RCC->APB1ENR = RCC->APB1ENR | 0x00000001 ; /* Enable clock TIM2 */
TIM2->ARR = 3332 ;
TIM2->PSC = 7199 ;
TIM2->DIER = TIM2->DIER | 0x0001 ; /* Autorisation interruption du timer */

/* Autorisation interruption */

RCC->CIR = RCC->CIR | 0x00000F00 ; /* Autorisation interruption en fonction de l'horloge*/
NVIC->ISER[0] = NVIC->ISER[0] | (1 << 28); /* activation de l'interruption 28 */
NVIC->IP[28] = NVIC->IP[28] | (1 << 4); /* Priorité (1) */

/* Lancement du timer */

TIM2->CR1 = TIM2->CR1 | 0x0001 ;

/* Debordement Timer */

while(1)
{

}

}

void TIM2_IRQHandler(void){

TIM2->SR = TIM2->SR & 0xFFFE ; /* Remise à 0 du bit UIF */

/* Allumage LED toutes les secondes */
/* Allumage/ETEINT LED */

GPIOA->ODR = GPIOA->ODR ^ (1 << 5);

}

 

Have you got some remarks about it ? why my code does not work when I flash it in my MCU ? 

 

Thanks a lot,

 

Charley

Outcomes