86 questions
2
votes
1
answer
58
views
Assistance with inline Assembly porting to SDCC
I am porting the GetCurrentMicro function in the Arduino Core STM8 to my SDCC code and I noticed the Cosmic C Compiler _asm function allows me to return a result as well as an input in a C var.
Is ...
2
votes
0
answers
113
views
External Interrupt on Port A is affecting functionality of my other Button Inputs on STM8S103F3P6 microcontroller
I've been working on a IR based light controller using STM8S microcontroller. Using this blog as reference text I've got the IR to work on pin PA1, according to my use case.
The issue I'm facing is ...
1
vote
1
answer
65
views
STM8 Timer1 glitch or stalling issue
Timer error 1 in STM8S003F3P
I am writing code to create overflow 1s = Timer 1 to reduce the remaining_sec variable from 60 to 1. But the Timer often hangs for a while at random times.
For example, ...
1
vote
1
answer
51
views
STM8L152R8 board LED not turning on
I have been working with the STM8L152R8 development board, but it does not seem to let me blink LD2 (which should be mapped to PB5) or really change any value at all. Here is my code. Thanks!
#include ...
0
votes
2
answers
243
views
SWIM on STM8 does not respond on activation sequence by synchronization frame
I'm trying to work make SWIM activation sequence for STM8 by external microcontroller of another company.
I use timing diagram from UM0470
In phase 4 STM8 should respond to host by keeping swim pin ...
2
votes
0
answers
61
views
Unmasking SPI Interrupt for both TXE and RXNE on STM8S105
I am writing some firmware for an STM8S, and I want to have my SPI transmissions and receptions be handled in an ISR rather than polling.
According to pg. 284 of the reference manual, I should be ...
1
vote
1
answer
449
views
How to import STM8S/A Standard peripheral library in a STM8 project (ST Visual Develop)?
I'm new to STM8 programming and I'm using the STM8S/A Standard peripheral library without importing it, that is, copying and pasting the files into my src and inc folders, which I don't think is the ...
1
vote
1
answer
278
views
Evaluation if conditional statement on ST Visual Developer with Cosmic for STM8
I am using STVD IDE to write code for STM8 the compiler I am using is Cosmic STM8 C compiler and the standard peripheral library provided for STM8.
The problem I have is while evaluating an if ...
1
vote
0
answers
153
views
Stm8l mcu RTC calibration problem using RTC_SmoothCalibConfig()
stm8l151k4 mcu
rtc external crystal works stably but returns error when I want to write calibration value.
"RTC_SmoothCalibConfig(RTC_SmoothCalibPeriod_32sec, RTC_SmoothCalibPlusPulses_Reset,50);&...
1
vote
1
answer
263
views
STM8 Assembly startup code: Access Core registers to initialize stack pointer
I am currently trying to write startup code in assembly for an STM8 without any vendor libraries. More specifically, I am using an STM8S103f3p6. I am still inexperienced in assembly and with startup ...
1
vote
0
answers
72
views
stm8s003 timer1 channel2 capture doesn't work
this doesn't work:
TIM1_CCMR2 = 0b01; //its default input channel
TIM1_IER = 0b100; //channel 2 capture interrupt
TIM1_CCER2 = 0b1; //channel 2 capture
TIM1_CR1 = 0b1; //start counter
...
0
votes
0
answers
146
views
Will IAR complier optimization causing trouble on code running?
the code is using IAR High Level optimization with STM8L151G3, and I observed some problems on the production unit.
In each loop, the code will execute the code below:
__IO uint8_t ColorSwapFlag = 0;
...
0
votes
1
answer
866
views
Stm8 Option Byte Programming
I want to program "Option Byte" on STM8S005k6 without stvp. I do it by programming its code on Option Byte area but this makes it write protected only, not read protected:
void ...
0
votes
1
answer
244
views
STM8S003F3 tim2 configuration
I am using STM8S Cosmic C compiler, and I am trying to configure tim2 for 350 µs (350 µs should be the pulse width).
As per the reference manual, tim4 is a 16-bit with a prescaler factor of 32768. I ...
0
votes
1
answer
320
views
Stm8 assembly instructions
I am trying to learn some basic fw reverse engineering but I need some help. I am complete novice when it comes to asm but I do have some background on other languages.
What does the following line do?...
2
votes
1
answer
623
views
Unable to send data with I2C using STM8s in C
I'm an engineering student and for my bachelor thesis I use a 16 channel IO expander which communicates with I2C with a STM8S microcontroller.
IDE: STVD (I set the correct ARF6 byte)
IO-ex: PCA8575 -&...
1
vote
1
answer
341
views
is there a HAL_SPI_transmit function in stm8?
I'm trying to write a stm32 code in stm8. The problem is I can't find a SPI_Transmit function only SPI_SendData. I need this function to transmit an array through SPI.
The stm32 SPI_transmit function ...
0
votes
0
answers
123
views
SPI communication on STM8 controller doesn't work
I'm trying to send data through spi with the Stm8 controller. The problem is that I can't see anything happening on the oscilloscope (even the SPI clock doesn't show) on the pins 6 and 5 with this ...
2
votes
2
answers
188
views
Why is the array size unknown?
I tried to program this code on an STM8 Controller:
#include "Imagedata.h"
void main(void)
{
unsigned char *pArray;
pArray=IMAGE_DATA;
while(pArray<=(IMAGE_DATA+(sizeof(...
0
votes
0
answers
82
views
Rapberry pi 4 serial communication with STM8S208RB not working properly
I'm trying to connect a raspberry pi 4B to a NUCLEO-8S208RB using serial communication connecting the device through tx/rx pins. Data sent from the STM board gets received by raspberry, but messages ...
1
vote
1
answer
276
views
[C]unrecognized token "@address" on VScode
I'm using cosmic compiler for stm8 microcontroller.
It supports "@" pointers or modifiers.
such like
@<address>
@far
@near
@tiny
@interrupt
@inline
//etc..
Cosmic compiler user guide
...
0
votes
1
answer
501
views
how to make stm8s003f3 do 38khz frequency on timer1?
i want to do some rc5 transmitter project.
i already have a circuit with a stm8s003 to send data and a ne555 to make 38khz frequency. with connect them together and send the specific data my rc5 ...
1
vote
1
answer
298
views
STM8 default EEPROM values COSMIC compiler
I'm developing a program using COSMIC 'C' compiler Ver 4.5.3 for STM8 CPU (STM8S003K3) and I want fill the MCU EEPROM with default values during mass production using ST-LINK/V2 device.
In the Manual ...
-1
votes
1
answer
212
views
COSMIC C - How to add assembler file to C code
I am getting this error when using atomthreads in cosmic c for stm8L151c6 micro controller.
clnk - symbol _archFirstThreadRestore not defined (Debug\atomkernel.o)
Ifound out that ...
1
vote
2
answers
976
views
STM8 as SPI slave can't send back data
I have build a prototype board with a STM8L, and I want it to be used and configured as a SPI slave. I am testing it with a raspberry pi as master.
I use the lib provided by ST called "STM8 ...
1
vote
2
answers
339
views
How to Convert the last digit of a number to a char and display it on LCD?
I recently got a STM8 MCU and it has the built in function LCD_GLASS_DisplayString("STRING")
The problem with that function is, as you can see below, that I cannot directly display an ...
1
vote
0
answers
175
views
How to link denser code in IAR in split sections?
I make the program for STM8L151G6 on IAR Embedded Workbench for STM8 (version 3.11.1)
I need to place the instruction JPF 0xf000 at 0x008426 address.
I do this. In C code:
__root static const uint8_t ...
0
votes
1
answer
914
views
Refering in code to section placed in RAM, cause linker error [Lc036]
STM8, IAR compiler.
Im trying to place changable interrupt vector table(IVT) in RAM(ram_ivt_section or RAM_IVT), stating from 0x00 address.
Prereq: Hardware entry point(base_ivt_section or IVT_TO_RAM ...
0
votes
1
answer
225
views
SDCC generates unnecessary division by zero
I'm using SDCC to compile for a STM8 microcontroller. Compiling the following file results in a seemingly unnecessary div instruction - which is very slow on the STM8.
char a[1];
char b;
void foo() ...
0
votes
1
answer
2k
views
How to get STM8 interrupts working properly
I want a main routine that runs continually but can be interrupted. I am at a loss as to how to get the UART or ADC interrupt to work properly. They only behave as expected if my main loop has wait-...
0
votes
1
answer
585
views
stm8 uart tx interrupt issue
I am programming a STM8S103F3 to TX on UART via interrupt. I understand a write to DR after "Transmit data register empty interrupt" will start another TX, so I have this in my ISR. But it ...
1
vote
1
answer
3k
views
Dump the firmware from an STM8 microcontroller
I have a 600W digital step up converter with broken STM8S103K3T6C and another that is currently working OK. Is there a way to copy (dump) firmware from the working one and upload it to the new chip. ...
0
votes
1
answer
544
views
"invalid indirection operand" error when passing a struct to function in Cosmic compiler and STM8
I am writing a firmware for stm8 with Cosmic compiler and in ST Visual Develop. I am using astruct as the following:
typedef enum
{
lcBlack = 0,
lcRed,
lcGreen,
lcOrange
}
led_color_t;
...
0
votes
1
answer
453
views
Issue in interfacing E-Ink display with STM8S103F3P6 microcontroller
I am using Waveshare 1.54" ePaper Module. Using SPI peripheral:
CPU freq is 16Mhz
SPI Prescaler DIV by 8
MSB FIRST
CPOL=0, CPHA=1
The Display does not response but it respond with TI CC1310 ...
0
votes
3
answers
1k
views
STM8 pulse counter
I am developing a control for a DC motor. This motor has an encoder that generates pulses according to its movement.
I need to control the number of turns of the motor shaft by monitoring the number ...
1
vote
0
answers
79
views
stm8s cco flag never set
I have a discovery stm8s003k board and when I tested a program for cco capability it seems cco will never be stable and program always remain in line: while(CLK_GetFlagStatus(CLK_FLAG_CCORDY) == FALSE)...
-1
votes
1
answer
447
views
TIM2 module is not ticking at 1 µs in STM8S103F3 controller
I created a program on STM8S103F3 to generate a delay in the range of microseconds using the TIM2 module, but the timer is not ticking as expected, and when I tried to call a 5-second delay using it, ...
1
vote
1
answer
2k
views
How to correctly read data returned by MFRC522 via SPI using STM8S103F3?
I had tested reading Mifare RFID 1K cards with an RFID-RC522 module via UART using a Pyhton script on my PC. Now I am using STM8S103F3 to interface with the same RFID-RC522 (MFRC522) via SPI, but I ...
0
votes
1
answer
824
views
UART issue for reading 2 bytes length
I am having an issue with the UART1 communication between two devices (Computer and a STM8S2 board).
I implemented software in the computer that writes two bytes length of data to the STM8
• the first ...
0
votes
1
answer
750
views
STM8 UART polling receive is mangles
I'm trying to connect to an STM8 using uart. The STM seems to transmit data OK, but what it receives seems to be mostly junk, and often seems to receive 2 bytes at once. Here's the code:
#include &...
1
vote
0
answers
263
views
C typedef enum "impossible" value in debug mode
On a STM8S, using the config files, on one hand I have (stm8s.h file)
typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus, BitStatus, BitAction;
and, in one of my functions (fonctions.c file),...
-1
votes
1
answer
248
views
How to declare RAM variable as volatile in STM8 assembly language
I want to know how i can declare any RAM variable as volatile in STM8 assembly language. I have one variable, which is shared between ISR and main function. It is causing issue during updates, when ...
1
vote
2
answers
145
views
Has anyone figured out how to program the STWBC-MC module by STM?
The documents say that we can flash custom firmware on this module but it doesn't say how. I am unable to locate any build tool chain either. I tried raising a customer support ticket with STM and ...
0
votes
1
answer
314
views
STM8L051F3 GPIO Initial Config
I am programming the STM8L051F3 processor for a simple application in which it is only necessary to control all GPIO.
The problem is that I can't control the GPIOC pin 0.
I just configured the GPIO ...
0
votes
2
answers
2k
views
stm8flash .bin file for EEPROM write
I am attempting to write values directly to the eeprom space on a stm8 micro controller. I don't want to write a program that does this that I flash onto the chip. But i want to write directly to it. ...
0
votes
1
answer
2k
views
Explanation about missing prototype error
I am getting the following error #error cpstm8 main.c missing prototype, but what I do not understand is the reason that I am receiving it, I declared the prototype of my function on the top and this ...
0
votes
1
answer
278
views
How can i configure pins "PD6 and PD5" of controller "STM8S103F3" in low state (voltage level 0) in "input mode"
I am using "STM8S103F3" controller. When i am reading the voltage levels on the pins "PD6 and PD5" on startup (no external connection), using "IDR" registers, it is showing voltage level as 1 (5v). I ...
0
votes
1
answer
622
views
How to verify memory checksum of the code in STM8S controller
I am using "STM8103F3" controller. I want to perform ROM test in my code, but i am unable to find the register, which can verify my "memory checksum". Memory checksum i can get my adding the "ROM" ...
0
votes
2
answers
600
views
STM8A CAN Filtering in Standard Peripheral Library
I am working with the STM8AF5286UDY and am trying to set up a CAN interface.
For programming, I use the standard peripheral library. At the moment, my CAN interface works fine. The only thing, which ...
1
vote
0
answers
356
views
STM 8 register addresses
My question has to do with how STM8 microcontrollers address things. Maybe Im missing something, I wrote a small program where the problem exists. The weird thing is that its different on my computer ...