2012-03-23 01:07 PM
Having difficulty getting UART5 to do anything on STM32F407
#stm32f407-uart2012-03-23 02:03 PM
(no text)
The forum would appear to have eaten your carefully crafted question, please try again.2012-03-23 02:55 PM
Worst forum software ever indeed. There's FOSS forum software out there that actually works - why not use it?
My problem boils down to not having UART5 do anything. I can send data in and have nothing show up in the receive buffer. I can send data out and see no wiggles on the line. My first assumption is that I've done something dumb in the configuration:Based on the examples in the STM32F4 standard peripheral library, I don't see any reason why this should not work. I have some, but not great, ability to see the states of registers. I'm using Ride7 but it doesn't have full register decoding yet.2012-03-23 05:05 PM
I have the same problem, I try to program the STM32, I configure the USART1 but dosen't work, I'm working in uVision Keil and coocox, at next, the main code.
#include ''stm32f10x_gpio.h''#include ''stm32f10x_i2c.h''#include ''stm32f10x_rcc.h''#include ''stm32f10x_usart.h''#include ''stm32f10x_conf.h''#include <stdio.h>USART_InitTypeDef USART_InitTypeDef1={ 115200, USART_WordLength_8b, USART_StopBits_1, USART_Parity_No, (USART_Mode_Rx | USART_Mode_Tx ), USART_HardwareFlowControl_None};void uart_init(){ RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOA | RCC_APB2Periph_USART1,ENABLE); GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_Init(GPIOA, &GPIO_InitStructure); USART_Init(USART1,&USART_InitTypeDef1); USART_Cmd(USART1,ENABLE);}int main(void){ uart_init(); printf(''Welcome!\r\n''); while(1) { }}2012-03-23 05:07 PM
any suggestions?
2012-03-23 07:52 PM
Did you try the standard Periph Lib example for F40x ? Better to start with the standard example..It always works !
Are you probing the UART pins on MCU or through a Level shifter like ST232 ? Anything else working on MCU ? Toggling of LED/Heartbeat or any GPIO..?2012-03-23 09:25 PM
GPIO_InitStructure.
GPIO_Pin
=
GPIO_PinSource12;
GPIO_Init
(
GPIOC,&
GPIO_InitStructure)
;
GPIO_InitStructure.
GPIO_Pin
=
GPIO_PinSource2;
GPIO_Init
(
GPIOD,&
GPIO_InitStructure)
;
2012-03-23 09:39 PM
any suggestions?
Please stop hijacking threads with off-topic questions. Open your own threads, and try not to double post the same question, the audience here is finite. STEP ONE : I've suggested before that you call your own print character routine to prove that works. STEP TWO : Once you confirm that, then you'll be in a better position to try retargeting/hosting STDIO functions for your tool chain. For Keil, something like this/*----------------------------------------------------------------------------
Write character to Serial Port
*----------------------------------------------------------------------------*/
int sendchar (int c) {
if (c == '
') {
while (!(USART1->SR & 0x0080));
USART1->DR = 0x0D;
}
while (!(USART1->SR & 0x0080));
USART1->DR = (c & 0x1FF);
return (c);
}
/*----------------------------------------------------------------------------
Read character from Serial Port (blocking read)
*----------------------------------------------------------------------------*/
int getkey (void) {
while (!(USART1->SR & 0x0020));
return (USART1->DR);
}
#include <
stdio.h
>
#include <
rt_misc.h
>
#pragma import(__use_no_semihosting_swi)
struct __FILE { int handle; /* Add whatever you need here */ };
FILE __stdout;
FILE __stdin;
int fputc(int ch, FILE *f) {
return (sendchar(ch));
}
int fgetc(FILE *f) {
return (getkey());
}
int ferror(FILE *f) {
/* Your implementation of ferror */
return EOF;
}
void _ttywrch(int ch) {
sendchar(ch);
}
void _sys_exit(int return_code) {
label: goto label; /* endless loop */
}
2012-03-23 11:59 PM
Brilliant, sir. That worked perfectly. I would never have spotted that on my own. Thank you very much!