Hi… I am transferring “TEST” string from the USART 1 to the hyper terminal. But at hyper terminal end I get only the char “T”. After that microcontroller unable to transfer the data. Please go through the following program, is there any problem in the code.This code is written for stm32 arm controller.
#include <stm32f10x_lib.h> #include <stdio.h> #include"stm32_reg.h"
int main() { unsigned char a[]="TEST",i; RCC->CFGR=0x001D8402; RCC->CR= 0x01010082; RCC->APB2ENR |= RCC_APB2ENR_AFIOEN ; AFIO->MAPR &= ~(1<<2) ; RCC->APB2ENR |= RCC_APB2ENR_IOPAEN; GPIOA->CRH &= ~(0xFFUL << 4); GPIOA->CRH |= (0x0BUL << 4); GPIOA->CRH |= (0x04UL << 8); RCC->APB2ENR |= RCC_APB2ENR_USART1EN; USART1->BRR |= 0x27<<4; USART1->BRR |=0x1; USART1->CR1= 0x0000; USART1->CR2=0x0000; USART1->CR3=0x0000; USART1->CR1|=0x8; USART1->CR1 |= USART_CR1_UE; for(i=0;i<7;i++) { USART1->DR=a[i] ; while (!(USART1->SR & USART_FLAG_TXE)); } }
Are you sure that you can read your own sourcecode ?!?!?
#include <stm32f10x_lib.h> #include <stdio.h> #include "stm32_reg.h" int main() { unsigned char a[]="TEST", i; RCC->CFGR = 0x001D8402; RCC->CR = 0x01010082; RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; AFIO->MAPR &= ~(1<<2); RCC->APB2ENR |= RCC_APB2ENR_IOPAEN; GPIOA->CRH &= ~(0xFFUL << 4); GPIOA->CRH |= (0x0BUL << 4); GPIOA->CRH |= (0x04UL << 8); RCC->APB2ENR |= RCC_APB2ENR_USART1EN; USART1->BRR |= 0x27<<4; USART1->BRR |= 0x1; USART1->CR1 = 0x0000; USART1->CR2 = 0x0000; USART1->CR3 = 0x0000; USART1->CR1 |= 0x8; USART1->CR1 |= USART_CR1_UE; for(i=0;i<7;i++) { USART1->DR=a[i]; while (!(USART1->SR & USART_FLAG_TXE)); } }
. BR, /th.
Nice to see the reply!! Your reply contains the same source code that i put on the forum. Plz go through it.
With one important difference - did you notice...?!
"Plz go through it"
Have you gone through it?
Have you stepped through it with the debugger?
Have you verified it against the chip's datasheet, and the examples provided by ST?
View all questions in Keil forum