cancel
Showing results for 
Search instead for 
Did you mean: 

COSMIC C Compilation error for STM8S003F3

vatsal_1770
Associate

 

This is one of function in code to implement WS2812 LED protocol on STM8S003F3.

vatsal_1770_2-1732674510642.png

And I am getting this error compilation.

----------- Project ws2812_led - STM8 Cosmic - Configuration Debug -------------

Compiling main.c...
cxstm8 -i..\led_blink\inc +debug -pxp -no -l +mods0 -pp -i"C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\Hstm8" -clDebug\ -coDebug\ main.c
#error cpstm8 main.c:34(9+7) invalid typedef usage
#error cpstm8 main.c:34(24) i undefined
main.c:
The command: "cxstm8 -i..\led_blink\inc +debug -pxp -no -l +mods0 -pp -i"C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\Hstm8" -clDebug\ -coDebug\ main.c " has failed, the returned value is: 1
exit code=1.

main.o - 4 error(s), 0 warning(s)


What could be the reason as I am using right data type? 

Regarding WS2812 addressable LED strip with STM8S003F3, Is there any library like FastLED is available for STM8? If not then is there any other way, because I am facing difficulties while achieving nano sec delay for this protocol.  


3 REPLIES 3
gabs
Associate II

As far as I remember, COSMIC does't accept variable declaration inside loops. Replace it for something like:

 

void ws2812_send_byte(uint8_t byte){
 uint8_t i=0;
 for(i=0;i<8;i++))
 {
  ...
 }
}

 

You can try to port FastLED to STM8

https://github.com/FastLED/FastLED/blob/master/PORTING.md

Googling around I've found this https://github.com/thielj/FastLED-STM8 but there's no documentation regarding the port, except reading the commits. Looks abandoned, but maybe it's a start point.

Good luck!

Regards 


@gabs wrote:

As far as I remember, COSMIC does't accept variable declaration inside loops.  


The option of a declaration was added in C99: https://en.cppreference.com/w/c/language/for

@vatsal_1770 so the question is, what C specification(s) does your compiler support?

Their documentation just says, "This implementation conforms with the ANSI and ISO Standard C specifications" - which is very vague.

https://www.cosmicsoftware.com/stm8.php

https://www.cosmicsoftware.com/pdf/cxstm8_pd.pdf

"ANSI C" is usually taken to mean C89 - which certainly doesn't support the variable declaraion within the for.

Use older C styles, where variables are defined as you open scope, ie '{'

For nano-second times, perhaps use the TIM, more directly/explicitly to drive PWM, or patterns for modulation.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..