cancel
Showing results for 
Search instead for 
Did you mean: 

STR912 Partiry bit set Error.

ikassma
Senior
Posted on April 09, 2014 at 13:48

hi.dear

i use to IAR compiler, default_form_lib_2.1_iar_5.30 library and jlink.

it is my developer environment.

 my chip is STR912FAW44.

first. i initialize UART2 set None parity bit.

second. i change to UART2 set  Even parity bit.

i check registor by jlink. it is ok changed Even parity bit.

but it was still operationg in non parity bit.

next is my initialize UART1 and baud rate change C code.

void UART1_Initial(void)

{

    /* Enable the UART0 Clock */

    SCU_APBPeriphClockConfig(__UART1, ENABLE);

    SCU_APBPeriphReset(__UART1,ENABLE);

    UART_DeInit(UART1); 

   

    GPIO_StructInit(&GPIO_InitStructure);       //Initialize the GPIO Init Structure parameters

   

    /*Gonfigure UART1_Rx pin GPIO3.2*/

    GPIO_InitStructure.GPIO_Direction = GPIO_PinInput;

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;

    GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ;

    GPIO_InitStructure.GPIO_IPInputConnected = GPIO_IPInputConnected_Enable;

    GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1  ;

    GPIO_Init(GPIO3, &GPIO_InitStructure);

   

    /*Gonfigure UART1_Tx pin GPIO3.3*/

    GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;

    GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ;

    GPIO_InitStructure.GPIO_IPInputConnected = GPIO_IPInputConnected_Disable;

    GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt2  ;

    GPIO_Init(GPIO3, &GPIO_InitStructure); 

    UART_InitStructure.UART_WordLength = UART_WordLength_8D;

    UART_InitStructure.UART_StopBits = UART_StopBits_1;

    UART_InitStructure.UART_Parity = UART_Parity_No ;

    UART_InitStructure.UART_BaudRate = 115200;

    UART_InitStructure.UART_HardwareFlowControl = UART_HardwareFlowControl_None;     // no flow controll

    UART_InitStructure.UART_Mode = UART_Mode_Tx_Rx;

    UART_InitStructure.UART_FIFO = UART_FIFO_Disable;  

   

size 16 bytes, FIFO level 8 bytes */

    UART_Init(UART1, &UART_InitStructure);

    UART_ITConfig(UART1, UART_IT_Receive | UART_IT_Transmit, ENABLE);  

   

    VIC_Config(UART1_ITLine, VIC_IRQ, 5);

    VIC_ITCmd(UART1_ITLine, ENABLE); 

   

    /* Enable the UART0 */

    UART_Cmd(UART1, ENABLE);

}

void uart1_baudrate_set(INT32U baud)

{

    UART_InitStructure.UART_WordLength = UART_WordLength_8D;

    UART_InitStructure.UART_StopBits = UART_StopBits_1;

    UART_InitStructure.UART_Parity = UART_Parity_Even ;

   

    switch(baud)

    {

        case BAUD_RATE_9600:

        case BAUD_RATE_19200:

        case BAUD_RATE_38400:

        case BAUD_RATE_57600:

        case BAUD_RATE_115200:

            UART_InitStructure.UART_BaudRate = baud;

            break;

        default :

            UART_InitStructure.UART_BaudRate = 115200;

            break;

    }

    UART_InitStructure.UART_HardwareFlowControl = UART_HardwareFlowControl_None;  

    UART_InitStructure.UART_Mode = UART_Mode_Tx_Rx;

    UART_InitStructure.UART_FIFO = UART_FIFO_Disable; 

   

    UART_Init(UART1, &UART_InitStructure);

}

I

can not

understand this situation

.

i want to solution.

3 REPLIES 3
Posted on April 11, 2014 at 02:27

Perhaps you need to ensure that any/all transmissions/receptions are complete, disable the UART, and then change the baud/parity, before re-enabling the UART.

It's been a while since I was actively using STR9 parts, switching baud rates on the STM32 I know is possible via this technique.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
ikassma
Senior
Posted on April 11, 2014 at 03:19

Yes,i agree. 

so.....

The cause of the problem

is that

you

know?

I solved of problem in your method. But I would like to know the cause of the problem.

Pantuca.Erwin
Associate II
Posted on May 26, 2014 at 06:43

i briefly checked the reference manual of the uart.  it mentions there both for the baud rate register and line control register:

The baud rate must not be changed: 

- When the UART is enabled.

- When completing a transmission or reception when it has been programmed to 

become disabled.

The line control register must not be changed :

- when the UART is enabled.

- when completing a transmission or a reception when it has been programmed to become 

disabled.