AnsweredAssumed Answered

Call to Systick_config causes program to hang

Question asked by fairchild.eddie on Jun 19, 2016
Latest reply on Jun 22, 2016 by fairchild.eddie
Once I comment out the call to systick it all works as expected, any idea why?

I have an Stm32f103c8t6 64kb but Keil thinks its 128kb I changed it to 64 in the debugger settings but aside from that I'm not sure what else needs changing or if that is causing the problem. Some googling mention something about liker scripts, I am afraid I am not far enough into this endeavor to know what that is

#include "stm32f10x.h"
 
 
 
 
//prototypes
 
void GPIO_initialize(void);
void USART_initlialize(void);
int putChar(int);
     
 
int main ()
{
 
    SystemInit();
    //SysTick_Config(1000);
     
 
     
     
    GPIO_initialize();
    USART_initlialize();
     
    volatile int i ;
     
    while(1)
    {
            for(i=0; i<=2000000;i++);
            GPIOC->BSRR = 1<<13;
            for(i=0; i<=2000000;i++);
            GPIOC->BSRR = 1<<29;
            putChar('o');
    }
     
}
 
int putChar(int c)
{
     
    while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
     
    USART1->DR = (c & 0xff);
     
    return 1;
     
}
 
int getChar(void)
{
     
    while(USART_GetFlagStatus(USART1, USART_FLAG_RXNE) == RESET) ;
     
    return USART1->DR&0xff;
     
     
}
 
void USART_initlialize()
{
    //initialize GPIOA, ALternate FUnction Clock , UART1
    //RCC->APB2ENR |= (1<<14) | (1<<0) | (1<<2);
     
    //same as above, using STDPeripheral Library
    //RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOA ,ENABLE);
     
     
 
     
    //initialize UART settings
    USART_InitTypeDef myUART;
    USART_StructInit(&myUART);
     
    myUART.USART_BaudRate = 9600;
    myUART.USART_Mode = USART_Mode_Rx | USART_Mode_Tx ;
    USART_Init(USART1, &myUART);
     
    USART_Cmd(USART1 , ENABLE);
     
     
     
}
 
 
void GPIO_initialize()
{
     
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOA ,ENABLE);
     
     
     
    RCC->APB2ENR |= 1<<4;
    GPIO_InitTypeDef myGPIO;
    GPIO_StructInit(&myGPIO);
    myGPIO.GPIO_Pin = GPIO_Pin_13;
    myGPIO.GPIO_Mode = GPIO_Mode_Out_PP;
    myGPIO.GPIO_Speed = GPIO_Speed_2MHz;
     
    GPIO_Init(GPIOC, &myGPIO);
     
     
        //initialize TX///////////////////////////////////
    GPIO_InitTypeDef uartGPIO;
    GPIO_StructInit(&uartGPIO);
     
    uartGPIO.GPIO_Pin = GPIO_Pin_9 ;
    uartGPIO.GPIO_Speed = GPIO_Speed_50MHz ;
    uartGPIO.GPIO_Mode = GPIO_Mode_AF_PP;
     
    GPIO_Init(GPIOA, &uartGPIO);
    /////////////////////////////////////////////////
     
    //initialize RX
    GPIO_InitTypeDef rxGPIO;
    GPIO_StructInit(&rxGPIO);
     
    rxGPIO.GPIO_Pin = GPIO_Pin_10;
    rxGPIO.GPIO_Mode =GPIO_Mode_IN_FLOATING;
     
    GPIO_Init(GPIOA , &rxGPIO);
     
    ///////////////////////////////////////////////////
     
     
}

Outcomes