2018-12-17 11:03 PM
i am using STM8L101F1.I happen to go through the datasheet and i found that the pin of the IC can be multiplexed.But i couldn't find any registers specified with the alternate functions for the pins of the controller.
the following pins have the spi functions:
PB7:MISO
PB6:MOSI
PB5:SCK
PB4:SPI_NSS
how should i go about configuring these pins for spi function.
2018-12-18 12:33 AM
In ST world, this kind of things are found not in the datasheet but in the reference manual - https://www.st.com/resource/en/reference_manual/CD00184503.pdf
10.7.1 Alternate function input
10.8.1 Alternate function output
19.3.2 Configuring the SPI in slave mode
19.3.3 Configuring the SPI master mode
2018-12-18 12:58 AM
The actual pin-out and alternate function table for STM32's is located in the datasheet, not the reference manual.
Other vendors put all in one document, not mentioning different naming preferences (datasheet, reference manual, hardware manual, etc. ).
2018-12-18 01:10 AM
True, but I was referring to this part (below) of the question, not the tables:
> i couldn't find any registers specified with the alternate functions for the pins of the controller.
Aren't the peripherals' registers descriptions in the RMs?
BTW, not that it matters, but this is about STM8, not STM32.
2018-12-18 03:44 AM
i configured spi mosi pin in pushpull mode as suggested by RM.
PB_DDR |= 0x80;
PB_CR1 |= 0x80;
BUT
am getting the error shown below:
#error cpstm8 main.c:24(1+6) PB_CR2 undefined
#error cpstm8 main.c:23(1+6) PB_CR1 undefined
main.c:
The command: "cxstm8 +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.
why is that so?
2018-12-18 04:11 AM
Are you using the peripheral library? Maybe it already has the features you need for setting the alternate functions (I don't use it so I don't know).
If not, then try to use GPIOB->DDR, GPIOB->CR1 and GPIOB->CR2 instead of PB_DDR, PB_CR1 and PB_CR2.
2018-12-18 04:16 AM
PB_DDR = 0x04;
PB_ODR = 0x04;
when i configure direction register Px_DDR only i'm not facing any issues, but when i configure Px_ODR the error shown below appears. I am using ST visual develop and compiler COSMIC.Is this issue due to lack of any header files. I have just added 2 header files .
#include <iostm8.h>
#include <stdio.h>
#error cpstm8 main.c:22(1+6) PB_ODR undefined
main.c:
The command: "cxstm8 +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.
2018-12-18 04:20 AM
i have include <stm8l.h> but got an error
#error cpstm8 main.c:4 can't open stml.h
main.c:
The command: "cxstm8 +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.
2018-12-18 04:36 AM
> BTW, not that it matters, but this is about STM8, not STM32.
This mediocre forum software uses to hide large parts of a post - like in this case.
But a speaking title for a thread (including the MCU it is about) is really helpful.
2018-12-18 11:38 PM
> #error cpstm8 main.c:4 can't open stml.h
Your project is probably not properly setup, i.e. some system include paths are missing.
> -l -i"C:\Program Files (x86)\COSMIC\FSE_Compilers\CXSTM8\Hstm8
These are the include paths I can identify. Try locating stml.h in your file system, and add the path to the includes.