cancel
Showing results for 
Search instead for 
Did you mean: 

Uart starts missing BYTEs and/or Packet when TIM0 Enabled

slanglois
Associate II
Posted on November 28, 2007 at 09:43

Uart starts missing BYTEs and/or Packet when TIM0 Enabled

1 REPLY 1
slanglois
Associate II
Posted on May 17, 2011 at 09:48

Hi,

My application use UART0 and a Timer (time base of 1ms) with the STR9. When I disable timer interrupt, everything is fine with the UART. When I enable the Timer, some packet are OK and randomly, it stops working. Something it looks like I receive the last TX that I've done.

I tried to use instead of the TIM0 (that has a bigger interrupt level than the UART) to use Periodical RTC (that has a lower interrupt level than the UART), but without success.

My UART settings are:

SCU_APBPeriphClockConfig(__UART0, ENABLE)

SCU_APBPeriphReset(__UART0,DISBLE)

UART_InitStructure.UART_WordLength = UART_WordLength_8D;

UART_InitStructure.UART_StopBits = UART_StopBits_1;

UART_InitStructure.UART_Parity = UART_Parity_No ;

UART_InitStructure.UART_BaudRate = 9600;

UART_InitStructure.UART_HardwareFlowControl =

UART_HardwareFlowControl_None;

UART_InitStructure.UART_Mode = UART_Mode_Tx_Rx;

UART_InitStructure.UART_FIFO = UART_FIFO_Disable;

UART_DeInit(UART0)

UART_ITConfig(UART0,UART_IT_Transmit,DISABLE)

UART_ITConfig(UART0, UART_IT_Receive,ENABLE)

VIC_Config(UART0_ITLine, VIC_IRQ,5)

VIC_ITCmd(UART0_ITLine,ENABLE)

UART_Init(UART0,&UART_InitStructure)

UART_Cmd(UART0,ENABLE);

My TIM0 Settings are :

SCU_APBPeriphClockConfig(__TIM01, ENABLE)

SCU_APBPeriphReset(__TIM01,DISBLE)

TIM_DeInit(TIM0)

VIC_Config(TIM0_ITLine, VIC_IRQ, 6)

VIC_ITCmd(TIM0_ITLine, ENABLE)

freq = SCU_GetPCLKFreqValue()

Tmr0_Cmp_Value = freq / TMR0_PRESCALER)

TIM0->OC1R = Tmr0_Cmp_Value

TIM_PrescalerConfig(TIM0, (TMR0_PRESCALER – 1))

TIM_CounterCmd(TIM0,TIM_START)

TIM_ITConfig(TIM0, TIM_IT_OC1, ENABLE)

My Alternative config of the RTC is:

SCU_APBPeriphClockConfig(__RTC, ENABLE)

SCU_APBPeriphReset(__RTC,DISBLE)

RTC_DeInit()

RTC_PeriodicIntConfig(RTC_Per_1024Hz);

VIC_Config(RTC_ITLine, VIC_IRQ, 6)

VIC_ITCmd(RTC_ITLine, ENABLE)

RTC_ITConfig(RTC_IT_Per, ENABLE)