stm8 | Wolk STM8 stuff
kandi X-RAY | stm8 Summary
kandi X-RAY | stm8 Summary
Wolk STM8 stuff
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of stm8
stm8 Key Features
stm8 Examples and Code Snippets
Community Discussions
Trending Discussions on stm8
QUESTION
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.
ANSWER
Answered 2021-May-05 at 13:42Looks like that's a bug somewhere in the compiler because if b = c >> 0
is changed to b = c << 0
, b = c + 0
, b = a[0]
... then no such thing happens. The behavior is observed on both optimized and unoptimized code. But if you optimize for size (--opt-code-size
) then only the div
is there, the clr
instruction isn't emitted. You might want to report that to the developers
QUESTION
on my STM8 Disco Board with Cosmic Compiler I tried follwoing code and expected 'ptr_a' and 'ptr_aLocal' to be the same:
...ANSWER
Answered 2020-Oct-27 at 14:12Various older versions of misc embedded compilers tended to optimize code somewhat even when optimizations were supposedly disabled. Particularly Cosmic and Codewarrior had such quirks in older versions. Since the local variable isn't used, it is optimized away.
You can see this for yourself by viewing the generated assembler - any half-decent debugger will support assembly step debugging. If there is no stack push or index register store instruction there, then it was optimized away.
You can force the variable to get used with volatile int *ptr_aLocal
.
Unrelated to your question, you should use uint8_t
as far as possible nad not int
, when programming 8 bit microcontrollers.
QUESTION
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. The command to do this is in unix is such:
...ANSWER
Answered 2020-Apr-09 at 22:17The easiest thing to do was to first read the file like so:
QUESTION
I see in STM32F103 series, the GPIO extra interrupt is set to the EXTI. And GPIOx_0 (x=A,B,C...)is set to EXTI0. Take an example, if I want to use PA0 and PB0 as interrupt input,can I set them to EXTI0 at the same time? I mean in the EXTI0_Handler function I read the value of the input register of PA0 and PB0 to judge which one input a electrical level I want to carry different function by using if...else
. I use it in STM8 successfully but there seems a little problem in STM32. Can you help me? Thanks.
The answer explains the problem clearly. The picture takes an example that why the four bits will be changed if you set different pins. You can see that the four bit affect by each other status if you config other pins. I ignore this problem before.
...ANSWER
Answered 2017-Dec-12 at 21:16If you look into the STM32F103 Reference Manual p. 209, you will see that there is actually a multiplexer that decides if PA0, PB0, ... or PG0 is connected to the EXTI0 signal:
That means that you cannot connect both PA0 and PB0 to EXTI0. In fact, there are four specific bits in the alternate function input/output register (AFIO) which let you choose which pin is connected to the EXTI0 signal. Here, these bits are located in the control register AFIO_EXTICR1. See the AFIO register map in the same document for further information.
Now I don't know which setup you are using, but as I recall, I had separate functions for different interrupt request routines (for EXTI0, EXTI1 and so on).
QUESTION
ANSWER
Answered 2020-Jan-17 at 14:35If you want to program uCs from your C application just use openOCD (free) and send commands to it. Works with almost every popular debug probe.
QUESTION
I want to use cpputest on STM8 and installed all the required tools for it. I am able to run cpputest on my simplified code. on my main file which belongs to the hardware I have of course the main function. But in the Test environment I have a main function under AllTests.cpp as well. When I compile it i get the error:
...ANSWER
Answered 2017-Nov-16 at 11:01As suggested in the commends, there was no other way to create a file with the main loop for only the Controller and separate it from the unit tests.
My structure looks like: main.c: - contains the includes from the firmware (app.h) and the main() with the run_app() app.c: contains all the firmware and is tested with cpputest
QUESTION
I'm trying to understand a program in assembly code which should be compiled with COSMIC
compiler to run on STM8
controller.
At the beginning of the program, there are a couple of xref
and xdef
and then comes a .dcall
statement or command. Here it is:
.dcall "2,0,__checksum16"
I searched the compiler's manual, the controller's programming manual and the internet in general but couldn't find what does this line mean.
Could someone please explain what does it mean and what are these comma-seperated entries mean?
...ANSWER
Answered 2019-Jul-06 at 12:03It is an assembler directive marking the entry point, symbol name and stack usage of a function.
According to this:
[...] the first integer is the stack space used by the call instruction plus any automatic storage used by the function. The second integer is the number of bytes stacked by the caller.
I suggest that given its name and function that it causes debug information to be inserted into the object file for use by the ZAP symbolic debugger. I am not familiar with the Cosmic tool chain, but it is also possibly used to perform stack depth analysis within the call graph by the linker.
QUESTION
I thought it should be as simple as:
...ANSWER
Answered 2019-Jul-16 at 09:23From the Cosmic compiler datasheet https://www.cosmic-software.com/pdf/cxstm8_pd.pdf
cxstm8 provides 2 different memory models depending on the size of the application.
For applications smaller that 64k, the “section 0” memory model provides the best code density by defaulting function calls and pointers to 2 bytes.
For applications bigger than 64k, the standard memory model provides the best flexibility for using easily the linear addressing space. Each model comes with its own set of libraries.
This may be the cause for your problem. If you want to access the memory location of above 16 bit address directly you need to use the correct memory model.
QUESTION
I programmed STM8 GPIO like PD_ODR_ODR4 = 1;
but stm32f10x.h doesn't have this function.Is there any .h file that has definition for bits.
Sorry but I don't know how to explain this problem better.
I tried multiple GPIO libraries.
strong text
...ANSWER
Answered 2019-Feb-18 at 10:58You mention stm32f10x.h
in the question, so I'm assuming it's about the STM32F1 series of controllers. Other series have some differences, but the general procedure is the same.
GPIO pins are arranged in banks of 16 called ports, each having it's own set of control registers, named GPIOA
, GPIOB
, etc. They are defined as pointers to GPIO_TypeDef
structures. There are 3 control registers that affect pin outputs.
Writing ODR
sets all 16 pins at once, e.g. GPIOB->ODR = 0xF00F
sets pins B0
through B3
and B12
through B15
to 1, and B4
through B11
to 0, regardless of their previous state. One can write GPIOD->ODR |= (1<<4)
to set pin GPIOD4
to 1, or GPIOD->ODR &= ~(1<<4)
to reset it.
Writing BSRR
treats the value written as two bitmasks. The low halfword is the set mask, bits with value 1 set the corresponding bit in ODR
to 1. The high halfword is the reset mask, bits with value 1 set the corresponding bit in ODR
to 0. GPIOC->BSRR = 0x000701E0
would set pins C5
though C8
to 1, reset C0
through C2
to 0, and leave all other port bits alone. Trying to both set and reset the same bit when writing BSRR
, then it will be set to 1.
Writing BRR
is the same as writing the reset bitmask in BSRR
, i.e. GPIOx->BRR = x
is equivalent to GPIOx->BSRR = (x << 16)
.
Now it's possible to write some macros like
QUESTION
I have a question regarding my Makefile. The Makefile intends to compile C files containing code for a STM8 µC using the Cosmic compiler. The problem is that everytime I invoke the build target, all available source file are getting recompiled without any change. I'm really new in the field of Makefiles and I have no idea how to fix it.
The second questions is related to the two targets "%.o: src/%.c" and %.o: src/stm8/%.c. They do exactly the same and I would prefer a generic one that is able to deal with all subdirectories within the src folder. With this solution it ist required to add an additional rule for each subfolder of the src folder
...ANSWER
Answered 2019-Jan-19 at 20:52The build
target never gets created, so the commands after it are executed every time you run make
(or make all
or make build
), so the program is linked each time.
Change your build
target so that it is phony:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install stm8
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page