I cant get my new stm32f103c8t6 board to blink a simple led. I have tried everything. I have written bare metal directly to the registers and also used GPIO libraries but its still not working. I am using keil. my led is connected on a breadboard across a 1k resistor . I have also tested the voltage across the output pin but its insignificant. What could be wrong please ? code below ...
#include "stm32f10x.h"
GPIO_InitTypeDef GPIO_InitStructure;
void delay(int a)
{
for (int i = 0; i < a; i++)
{
}
}
int main(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
/* Configure PD0 and PD2 in output pushpull mode */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_2;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOD, &GPIO_InitStructure);
/* To achieve GPIO toggling maximum frequency, the following sequence is mandatory.
You can monitor PD0 or PD2 on the scope to measure the output signal.
If you need to fine tune this frequency, you can add more GPIO set/reset
cycles to minimize more the infinite loop timing.
This code needs to be compiled with high speed optimization option. */
while (1)
{
/* Set PD0 and PD2 */
GPIOA->BSRR = 0x00000005;
delay(1000000);
/* Reset PD0 and PD2 */
GPIOA->BRR = 0x00000005;
delay(1000000);
}
}
GPIOD
but you are usingGPIOA
.... – LPsdelay
is likely ineffective. 3) Write the registers from the debugger for an initial test of the hardware. – too honest for this site