cancel
Showing results for 
Search instead for 
Did you mean: 

Serious USART1 RX Trouble

noman_iradat
Associate II
Posted on February 04, 2011 at 13:05

Serious USART1 RX Trouble

3 REPLIES 3
Posted on May 17, 2011 at 14:24

For the interrupts, be aware that NVIC_PriorityGroupConfig() is a global setting. You set it once, you don't keep changing it. Any premption/priority you select with NVIC_Init().

Also if you enable the TXE interrupt, you have to be ready to give the USART some data, otherwise you can't clear the condition, and you will get an interrupt storm which will preclude any other operation of foreground code.

Systick_Init() and RCC_Configuration(), both seem to set up the RCC and APB/AHB bus speeds. It reinitializes the RCC but doesn't reenable the clocks, lot of crap in Systick_Init() that could be purged.

Most everything else looks in order. How do you determine it is not receiving data? Can you make a loop/build that only does receive and test that? You could make a circular receive buffer, and park a memory view over it using the debugger. This would permit you to view data received without having to echo it some place else.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
noman_iradat
Associate II
Posted on May 17, 2011 at 14:24

Dear clive,

The Systick_Init() that I have used is only meant to initialize the TIM8 to interrupt every 10 milliseconds. Anyway I will try to purge the redundant settings from this function.

However I have not initialized the receive or transmit interrupts of  USART1 or USART2 as you can see in the function ''void USART1_Config(void)''. Only status flags are being checked for the events. Do you think that I should remove the following settings from NVIC_Configuration() function.

  /* Configure the NVIC Preemption Priority Bits */  

   NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);

  

  /* Enable the USART1 Interrupt */

   NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQChannel;

   NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

   NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

   NVIC_Init(&NVIC_InitStructure);

Whatever I receive from USART1 is being transmitted from USART2. The oscilloscope does show that the data from the external device is being transmitted on the receive pin of USART1. i.e. GPIO_Pin_10 of GPIOA.

Please tell me what should I do in order to receive the byte at USART1.

noman_iradat
Associate II
Posted on May 17, 2011 at 14:24

Hi Clive,

I implemented the changes you mentioned and now I can receive the data at USART1. Thanks !!!.