cancel
Showing results for 
Search instead for 
Did you mean: 

Board Bring-up with STM8L051F3

edmond yun
Associate II
Posted on June 26, 2018 at 13:12

Hi,

I need your help to find out the root cause of my issue,

please help to check the issue, thankful for your support in advance,

thanks.

issue,

when trying to do bring-up new board, we can't control any port related with LED.

Chip is STM8L051F3, used with STVP, IAR embedded workbench IDE - stm8

I can download hex file, but the symptom seems to be that CPU is no responsive, at all.....

please refer my code, I used STM8L15x_StdPeriph_Driver SDK, 

void main(void)

{

char ans;

/*High speed internal clock prescaler: 1*/

CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_1);

GPIO_Init(LED_R_GPIO_PORT, LED_R_GPIO_PINS, GPIO_Mode_Out_PP_Low_Slow);

GPIO_Init(LED_B_GPIO_PORT, LED_B_GPIO_PINS, GPIO_Mode_Out_PP_Low_Slow);

while (1)

{

/* Toggle LED_R LED_B */

GPIO_ToggleBits(LED_R_GPIO_PORT, LED_R_GPIO_PINS);//void GPIO_ToggleBits(GPIO_TypeDef* GPIOx, uint8_t GPIO_Pin)

Delay(100);

GPIO_ToggleBits(LED_B_GPIO_PORT, LED_B_GPIO_PINS);

}

and I set up the environment of IAR as follows, 

Option -> c/c++ Compiler -> Preprocessor 

In Defined symbols item, add 2 option,

USE_STM8L1526_EVAL

STM8L05X_LD_VL

please help to let me know what it is problem, if necessary, I can upload the circuit,

thankful for your concern in advance,

thanks.

#stm8l051f3
7 REPLIES 7
Artur IWANICKI
ST Employee
Posted on June 26, 2018 at 13:37

Hello,

What is behind your definitions: LED_R_GPIO_PORT, LED_R_GPIO_PINS,LED_G_GPIO_PORT, LED_G_GPIO_PINS.

Are you using internal default clock or some external crystal.

May I ask you for a part of the schematics with visible power pins, NRST, SWIM connector, please?

Thank you in advance

Best Regards,

Artur

henry.dick
Senior II
Posted on June 27, 2018 at 01:50

'

but the symptom seems to be that CPU is no responsive, at all.....'

can you inspect the port registers your code intend to change? do they change value as expected?

Posted on June 27, 2018 at 03:03

 ,

 ,

Hello, Artur, ,

Thankful for your concern, ,

I update the schematic, and more description for your questions, please refer it and give me your guide,

♯ define LED_R_GPIO_PORT GPIOC

 ,

♯ define LED_R_GPIO_PINS GPIO_Pin_0

♯ define LED_B_GPIO_PORT GPIOC

 ,

♯ define LED_B_GPIO_PINS GPIO_Pin_1

I am using internal clock and tried to change from 2 Mhz to 16 Mhz...with the following code,

But I can't see LED light in all case, the output voltage of LEDs is zero....

For 2 Mhz case(default case),

CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_1),

For 16 Mhz case, ,

// CLK_SYSCLKSourceSwitchCmd(ENABLE),

 ,

//

 ,

// CLK_SYSCLKSourceConfig(CLK_SYSCLKSource_HSI),

 ,

//

 ,

// CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_1),

 ,

//

 ,

// while (CLK_GetSYSCLKSource() != CLK_SYSCLKSource_HSI)

 ,

// {}0690X0000060LUPQA2.png

thanks.

Artur IWANICKI
ST Employee
Posted on June 27, 2018 at 12:10

Hello,

The problem is related to the fact that PC0 and PC1 are true open drain (no internal pull-up nor high side transistor in output configuration). To make it working you need to add external resistors.

Please have a look at datasheet into pins specification for more information.

Best Regards,

Artur

edmond yun
Associate II
Posted on June 27, 2018 at 14:31

Hello, 

today I got some progress, currently we can download binary image with IAR(Download and Debug function),

but I can't download the same image with STVP, it shows the red bar in programming step.....

maybe it seems to be failed so after that, I can see the same symptom, why ? this is first question,

secondly, I need to use 3 timer, I know that stm8l01F3 chip has 3 timers like 2/3/4 timers,

and 2/3 timers have 16 bit counter, and 4 timer has only 8 bit counter,

so I used 3 timer for PWM (250 Khz), and 4 timer for 1ms period, and then I am trying to make 5 us period with 2 timer,

but maybe it can't be implemented because TIM2CLK is only 8.192 KHz owing to it is mapped with LSE.....(32.768 Khz oscillator).. is it right ? 

if so, I can't implement what I want with this chip.... Please help to let me know whether my information is correct or not,and if having another solution, please help me by giving it with example.

finally(thirdly), as to Beep function, I wonder whether the following code is correct or not for the usage of beeper,

and I would like to know the method to increase volume with soft or HW.....please help me...

Code) the code can make the sound of beep currently.... 

CFG->GCR |= CFG_GCR_SWD; /*disable SWIM interface*/

CLK_PeripheralClockConfig(CLK_Peripheral_BEEP, ENABLE);

CLK_BEEPClockConfig(CLK_BEEPCLKSource_LSI);

BEEP_Init(BEEP_Frequency_2KHz);0690X0000060LV2QAM.png

thankful for your support in advance,

thanks.

Posted on June 28, 2018 at 07:08

Hi, Artur,

Could you please kindly help to review my issue that I updated below ?

Thankful for your kindness in advance,

thanks.

Posted on June 29, 2018 at 14:03

Hi, Dhenry,

I found something to solve issues, 

firstly, the gpio pins related with LED is wrongly selected, we changed it,

secondly, we found another solution to use beep function with the same port as SWIM....

thirdly, as to priority setting of timer, I can't find the method to set up the priority, 

but when trying to do something that I hope to do in interrupt service routine function directly,

I can control the gpio normally,....so the issue is solved,

but currently, I can't normally download image with STVP, we don't know the reason, 

Could you please kindly help us to know the reason ?

We worry whether our circuit is problem or not,....need your help to review it,

thankful for your support in advance,

thanks,.