cancel
Showing results for 
Search instead for 
Did you mean: 

Couldn't find the alternative function table specified for controller.

Amal Babu
Associate III

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.

10 REPLIES 10

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

AvaTar
Lead

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. ).

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.

Amal Babu
Associate III

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?

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.

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.

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.

> 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.

AvaTar
Lead

> #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.