2008-04-17 02:24 AM
SOLVED : USART_SendData
2011-05-17 03:30 AM
Hello,
I'm using USART_SendData function, and i'm surprised that when i transmit the value ''224''(decimal) i receive ''248''. USART_SendData(USART1, 224); or if I transmit ''65'' I receive ''224''.. my configuration : USART_InitStructure.USART_BaudRate = 9600; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; USART_InitStructure.USART_Clock = USART_Clock_Disable; USART_InitStructure.USART_CPOL = USART_CPOL_Low; USART_InitStructure.USART_CPHA = USART_CPHA_2Edge; USART_InitStructure.USART_LastBit = USART_LastBit_Disable; /* Configure the USART1 */ USART_Init(USART1, &USART_InitStructure); USART_Cmd(USART1, ENABLE); I don't understand .. thanks [ This message was edited by: julien.massot on 15-04-2008 15:43 ] [ This message was edited by: julien.massot on 17-04-2008 14:54 ]2011-05-17 03:30 AM
What is your host UART or other part configuration ?
2011-05-17 03:30 AM
My host Uart is the USART1, I'm using the firmware library um0427
GPIO : /* Configure USART1 Tx as alternate function push-pull */ GPIO_InitStructureU.GPIO_Pin = GPIO_Pin_9; GPIO_InitStructureU.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructureU.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, &GPIO_InitStructureU); /* Configure USART1 Rx (PD.10) as input floating */ GPIO_InitStructureU.GPIO_Pin = GPIO_Pin_10; GPIO_InitStructureU.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOA, &GPIO_InitStructureU); On my PC i launch a sniffer who reads the decimal value2011-05-17 03:30 AM
Bonjour Julien,
I mean what is the full configuration of the PC sniffer ? baudrate, partity, etc.. thank you. Cheers, STOne-32.2011-05-17 03:30 AM
Com6
baud 9600 Data 8 Parity none Stop 1 However this function works properly, and return the good value do { if((USART_GetFlagStatus(USART1, USART_FLAG_RXNE) != RESET)&&(RxCounter < RxBufferSize)) { RxBuffer[RxCounter] = USART_ReceiveData(USART1); USART_SendData(USART1, RxBuffer[RxCounter++]); } }while(RxCounter != RxBufferSize); strange..2011-05-17 03:30 AM
hi,
I don't know the USART peripheral, but couldn't help but notice that 224 = 0xE0 = 11100000 248 = 0xF8 = 11111000 it smells like maybe there's a significant difference (40%) in baud rate between transmitter and receiver. check your clock frequency. I assume you're using a crystal, the firmware lib expects the frequency of the external crystal in a #define directive. the default is 8MHz.2011-05-17 03:30 AM
Thanks,
I'm using an external crystal at 12Mhz, PLL factor is configure at 6 : RCC_PLLConfig(RCC_PLLSource_HSE_Div1,RCC_PLLMul_6); So i'm running at 72 Mhz.. I'm searching with gdb..2011-05-17 03:30 AM
Hi Julien,
lanchon suggestion is right and you should modifiy in the file called ''stm32f10x_conf.h'' Just before the Assert macro /* In the following line adjust the value of External High Speed oscillator (HSE) used in your application */ #define HSE_Value ((u32)8000000) /* Value of the External oscillator in Hz*/ By #define HSE_Value ((u32)12000000) /* Value of the External oscillator in Hz*/ Hope this is more clear now. Cheers, STOne-32.2011-05-17 03:30 AM
Thank you STOne and good suggestion Lanchon..
Now my Usart works properly...