UART Data coming in faster than I expect - K10

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

UART Data coming in faster than I expect - K10

跳至解决方案
2,853 次查看
ignisuti
Contributor IV

I'm creating a UART driver and had intially disabled the FIFO buffers at first. I was only receiving the first of 5 bytes of data.

I eventually decided to try and enable the FIFO buffers and find that ALL of the expected 5 bytes are present during my first interrupt. 

 

How can this be if I'm running my core clock at 100MHz? My MCU should be fast enough to get the interrupt after the first byte, pull the byte out of the buffer, increment the counter, and then go about it's business long before the 2nd byte arrives. Am I wrong here?

 

Note: I'm using UART 1.

0 项奖励
回复
1 解答
2,501 次查看
TomE
Specialist II

> Any thoughts on this theory?

 

The first time I say a debugger connected through the debug port with a window showing the results of "printf()" I had no idea how it could be doing that, so I looked further.

 

For this system (a long time ago on an MPC860) the debugger setup "secretly" put a breakpoint on a function deep in the printing code. The embedded printing code printed to a named ram-based buffer then called the function with the breakpoint on it. The CPU *STOPPED*, the debugger special-cased that breakpoint to mean "don't tell the user, just read the buffer, show in the window and then continue".


All this debugger interaction took a long time - like 1/2 second or more. With the CPU halted for all that time it can't do anything "real time".

 

is your one doing the same thing? If you need any "real time response" you can't have any of this sort of debugging. it may be time to replace it with printing to a real buffered and interrupt driven serial port, to a network connection, a file system or to a HUGE RAM-based print buffer that you look at later.

 

Tom

 

在原帖中查看解决方案

0 项奖励
回复
8 回复数
2,501 次查看
ignisuti
Contributor IV

Also... I'm using baud rate of 115200.

0 项奖励
回复
2,501 次查看
rhyttr
Contributor I

I had same problem before, cause i do something delay (eg. printf) in interrupt, so the next interrupt can not trigger

 

just remind you 

 

0 项奖励
回复
2,501 次查看
mjbcswitzerland
Specialist V

Hi

 

Have you tried changing the receive watermak register setting to configure how many bytes need to be received before an interrupt is generated?

 

Regards

 

Mark

 

0 项奖励
回复
2,501 次查看
ignisuti
Contributor IV

Hi guys. Thanks for the suggestions.

 

I removed all printf statements from my interrupt to test, but that did not correct things.

 

Also, I have my RXWATER set to 1.

 

What else can I check?

0 项奖励
回复
2,501 次查看
comsosysarch
Contributor III

Do you have any very large temprorary variables declared inside the ISR?

 

0 项奖励
回复
2,501 次查看
ignisuti
Contributor IV

Nope...

 

Now, I did come across something that looks suspect. There are a lot of printf commands processing in the background which the debugger is using to show data in the CW 10.2 terminal. 

 

Those printf commands seem to be super slow. I can watch the text being typed in the terminal. 

 

Maybe that's blocking/delaying so much that my interrupt isn't triggering fast enough... Any thoughts on this theory?

0 项奖励
回复
2,502 次查看
TomE
Specialist II

> Any thoughts on this theory?

 

The first time I say a debugger connected through the debug port with a window showing the results of "printf()" I had no idea how it could be doing that, so I looked further.

 

For this system (a long time ago on an MPC860) the debugger setup "secretly" put a breakpoint on a function deep in the printing code. The embedded printing code printed to a named ram-based buffer then called the function with the breakpoint on it. The CPU *STOPPED*, the debugger special-cased that breakpoint to mean "don't tell the user, just read the buffer, show in the window and then continue".


All this debugger interaction took a long time - like 1/2 second or more. With the CPU halted for all that time it can't do anything "real time".

 

is your one doing the same thing? If you need any "real time response" you can't have any of this sort of debugging. it may be time to replace it with printing to a real buffered and interrupt driven serial port, to a network connection, a file system or to a HUGE RAM-based print buffer that you look at later.

 

Tom

 

0 项奖励
回复
2,501 次查看
ignisuti
Contributor IV

TomE,


Yes, that sounds exactly like what's going on. I was seeing huge BLOCKING delays in the neighborhood of seconds.

0 项奖励
回复