AnsweredAssumed Answered

how to configure stm8s microcontroller's internal oscillator clock in STVD evironment?

Question asked by KANDASAMY.GURUMOORTH on Mar 22, 2017
Latest reply on Mar 23, 2017 by Ian Legg

microcontroller :stm8s003f3p6


when I am trying to upload the code it shows following error


Error : Cannot communicate with the device !


so I was thinking this error is shown because the internal oscillator is not configured.


then I have used following internal clock configuration in STVD but it is showing error following error


void InitialiseSystemClock()
CLK_ICKR = 0; // Reset the Internal Clock Register.
CLK_ICKR_HSIEN = 1; // Enable the HSI.
CLK_ECKR = 0; // Disable the external clock.
while (CLK_ICKR_HSIRDY == 0); // Wait for the HSI to be ready for use.
CLK_CKDIVR = 0; // Ensure the clocks are running at full speed.
CLK_PCKENR1 = 0xff; // Enable all peripheral clocks.
CLK_PCKENR2 = 0xff; // Ditto.
CLK_CCOR = 0; // Turn off CCO.
CLK_HSITRIMR = 0; // Turn off any HSIU trimming.
CLK_SWIMCCR = 0; // Set SWIM to run at clock / 2.
CLK_SWR = 0xe1; // Use HSI as the clock source.
CLK_SWCR = 0; // Reset the clock switch control register.
CLK_SWCR_SWEN = 1; // Enable switching.
while (CLK_SWCR_SWBSY != 0); // Pause while the clock switch is busy.


#error cpstm8 main.c:13(17) invalid lvalue
#error cpstm8 main.c:22(16) invalid lvalue
#error cpstm8 main.c:21(0+8) CLK_SWCR undefined
#error cpstm8 main.c:20(0+7) CLK_SWR undefined
#error cpstm8 main.c:19(0+11) CLK_SWIMCCR undefined
#error cpstm8 main.c:18(0+12) CLK_HSITRIMR undefined
#error cpstm8 main.c:17(0+11) CLK_PCKENR2 undefined
#error cpstm8 main.c:16(0+11) CLK_PCKENR1 undefined
#error cpstm8 main.c:15(0+10) CLK_CKDIVR undefined
#error cpstm8 main.c:14(0+8) CLK_ECKR undefined
#error cpstm8 main.c:12(0+8) CLK_ICKR undefined
#error cpstm8 main.c:41(7) missing prototype