2012-11-20 02:34 PM
Hello,
I looking for some example code for communication between my ST-DISCOVERY F0 board and PC (UART). Can someone help me with it? I´m novice.Thank you2014-04-11 09:18 AM
The forum does not support mobile devices very well. Always Top-Post responses, quoting the prior message is optional as we can see all posts to the thread.
2014-08-27 03:05 AM
I'm trying to connect STM32F0 with the pc using the following converter :
http://www.amazon.it/gp/product/B00AFRXKFU/ref=pe_115971_53225081_em_1p_0_ti
I'm not sure if is good for this purpose but for now it not work. I connected the pin in the following way:http://itinypic.com/osra1d.jpg
Here is the code used:
#include ''stm32f0xx.h''
int
main(
void
)
{
USART_InitTypeDef USART_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_1);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_1);
/* Configure USART1 pins: Rx and Tx ----------------------------*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
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_Init(USART1, &USART_InitStructure);
USART_Cmd(USART1,ENABLE);
while
(1)
{
while
(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
USART_SendData(USART1,
'X'
);}
}
I used different programs to read data from the micro:
Tera Term
Realterm
Putty
terminal v19b
2014-08-27 03:40 AM
You have the cable sense backward, switch the black and white cables at the USB serial dongle.
The TX (OUT) of the STM32 must go to the RX (IN) of the USB serial dongle.2014-08-27 03:50 AM
I made a mistake big mistake, sorry.
Now it works perfectly. Thank you very much.2014-12-12 04:55 AM
Hello sir,I too have been trying to communicate using USART2 on STM32f107VC,but it seems as if I get some garbage values on hyterminal.Can you help me with it.
void USART_Configuration(void){ GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; // RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA | RCC_APB1Periph_USART2,ENABLE); RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA,ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE); /* * USART1_TX -> PA2 , USART1_RX -> PA3 */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); USART_InitStructure.USART_BaudRate = 115200; 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_Init(USART2, &USART_InitStructure); // USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);// USART_ITConfig(USART2, USART_IT_TXE, ENABLE); USART_Cmd(USART2, ENABLE);}int main(void){ NVIC_Configuration(); USART_Configuration(); printf(''* Thank you for using HY-MiniSTM32V Development Board ! ^_^ *\r\n''); /* Infinite loop */ while (1) { /* Loop until RXNE = 1 */ while (USART_GetFlagStatus(USART2, USART_FLAG_RXNE) == RESET); USART_SendData(USART2,'x'); }}2014-12-12 05:10 AM
Then you don't really have an STM32F0 device then do you? Please if you're off topic start a new thread.
You need to be waiting on TXE (Transmit Empty) for outbound characters, not RXNE (Receive Not Empty). Electrically the USART pins are CMOS levels, not RS232 levels which would require a level converter chip.2015-04-23 01:29 PM
to be migrated, sourceId: 13782:74F499D6-C293-4561-BFB5-4F1489999957
2015-04-23 01:32 PM
to be migrated, sourceId: 13783:74F499D6-C293-4561-BFB5-4F1489999957
2015-04-23 01:48 PM
Confusion here with pointers, you have a variable, it isn't moving, you pass a pointer to the function.
int k;
uint8_t rx;
for (k = 0; k < 8; k++) { // 8 bytes
fifo_read(RxFifo, &rx, 1);
rx_packet[k] = rx;
}
int k;
for (k = 0; k < 8; k++) { // 8 bytes
fifo_read(RxFifo, &rx_packet[k] , 1);
}
fifo_read(RxFifo, rx_packet, 8); // Read it once?
2015-05-07 10:38 AM
How to make fifo_t structure and read, write functions acessible from more .c files? I tried to do this with header file, but when I put structure definition into this header I obtain error: typedef redefinition with different types (''struct fifo_t'' vs. ''struct fifo_t'').
What this mean?