AnsweredAssumed Answered

compiling ok but non funktional code

Question asked by kramer.andreas on Dec 8, 2011

Hi,
first sorry for my english (its not my native language).
I have a problem getting funktional code for an STM8S005C6 ( eval Board ).
I use the STVP with Raisonance C compiler and i am able to compile code without errors.
Very simple code pieces work ( like a blinking Led ).
But there seems to be an error with the clock. When i toggle a pin in a while(1) construct i can only meassure aprox 300 kHz frequency at the pin.
I think this should be much higher since systemclock is configured as HSI with devider 1.

Next thing is i can´t bring the sample prog ( AN3996 ) to work.
It compiles without errors but when i upload it an reset the board it isn´t working. The led is on the whole time without any reaction to the touch button.

My last try was to write a programm to communicate with the uart1. But it never sends anything. My programm is stuck at this part:

  /* Write X to the UART1 */
  UART1_SendData8('X');
  /* Loop until the end of transmission */
  while (UART1_GetFlagStatus(UART1_FLAG_TXE) == RESET)
  {
   GPIO_WriteReverse(GPIOD, GPIO_PIN_0);
   //It never leaves this loop
  }

The whole main.c is in the attachment. The other files are from the Project_template (AN3996).

Maybe anyone can give me a clue where to search or what to change that i can produce working code for the STM8S.  ( Oh i totaly forgot to mention that i can reupload the original working hexfile so it seems to be no hardware bug )

Greetings A.Kramer


EDIT: I found the source of my problem. The target declaration wasn´t the same in STVD and the makefile. There was a hidden wrong target and all code was compiled for the wrong device.

Outcomes