AnsweredAssumed Answered

Errors in firmware ?

Question asked by Pellek on Aug 21, 2012
Latest reply on Aug 22, 2012 by Pellek
Hi.

As i m currently working on an application running on both STM8S and STM32, i'm using firmware libraries to get a portable code. i already found several mistakes.

As an example : Software NSS bit.
- first mistake is in usermanual of STM8S, it is written :
Bit 0 SSI: Internal slave select
This bit has effect only when SSM bit is set. The value of this bit is forced onto the NSS pin and the I/O
value of the NSS pin is ignored.
0: Slave mode
1: Master mode

whereas it's
0 : NSS set to LOW
1 : NSS set to HIGH

2nd mistake is in firmware :
void SPI_NSSInternalSoftwareCmd(FunctionalState NewState)
{
    /* Check function parameters */
    assert_param(IS_FUNCTIONALSTATE_OK(NewState));

    if (NewState != DISABLE)
    {
        SPI->CR2 |= SPI_CR2_SSI; /* Set NSS pin internally by software*/
    }
    else
    {
        SPI->CR2 &= (uint8_t)(~SPI_CR2_SSI); /* Reset NSS pin internally by software*/
    }
}

So here, if i call this function:  SPI_NSSInternalSoftwareCmd(ENABLE);
it sets NSS to HIGH, and therefor DISABLE the communication....




Now that i m done with STM8S i m starting with stm32.
first function i try to port :
STM8S version :
GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef GPIO_Pin, GPIO_Mode_TypeDef GPIO_Mode)

stm32F1 version :
void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct)

I'm wondering why this change, to use a structure to regroup informations of pin# and pin_mode... That i have now to create a structure and then call the function for each pin i want to configure, whereas i only had to call 1 function before. But ok, welcome in 32-bit world ^^

and now in the definition of the structure you find :
typedef struct
{
  uint16_t GPIO_Pin;             /*!< Specifies the GPIO pins to be configured.
                                      This parameter can be any value of @ref GPIO_pins_define */

  GPIOSpeed_TypeDef GPIO_Speed;  /*!< Specifies the speed for the selected pins.
                                      This parameter can be a value of @ref GPIOSpeed_TypeDef */

  GPIOMode_TypeDef GPIO_Mode;    /*!< Specifies the operating mode for the selected pins.
                                      This parameter can be a value of @ref GPIOMode_TypeDef */
}GPIO_InitTypeDef;


and

typedef enum
{
  GPIO_Speed_10MHz = 1,
  GPIO_Speed_2MHz,
  GPIO_Speed_50MHz
}GPIOSpeed_TypeDef;

They aren't defining which value correspond to 2 and 50MHz, moreover, i find in datasheet :

Bits 29:28, 25:24,
21:20, 17:16, 13:12,
9:8, 5:4, 1:0

MODEy[1:0]: Port x mode bits (y= 0 .. 7)
These bits are written by software to configure the corresponding I/O port.
Refer to Table 16: Port bit configuration table on page 101.
00: Input mode (reset state)
01: Output mode, max speed 10 MHz.
10: Output mode, max speed 2 MHz.
11: Output mode, max speed 50 MHz.


So 10Mhz, shall be b"01" and not 1.

in GPIO_Init, they re loading the value of Speed directly into register at right position..


In conclusion when i see such mistakes, i wonder if there are erratas on ST firmware or if i shall definitly stop to use them ?

Outcomes