Log in

View Full Version : SEROUT loop with pause



Michael
- 3rd June 2021, 16:55
Force of habit or maybe there was a reason I put a pause after serout in a loop. I know that I discovered the hard way that I needed to do that in Python to keep the cpu from working too hard (and a little bit of pause made a huge difference).

But what about PIC's ?

I simply have --
START:
DO STUFF
SEROUT PORTA.0 T2400 (ETC)
PAUSE 200
GOTO START

Actually, I need to reduce it to 50 or so because I have it feeding a PI with a python script that's reading it but what effect does a pause have with a PIC's performance? Is a pause "good practice" or completely unnecessary? -- thanks much

tumbleweed
- 3rd June 2021, 22:55
Completely unnecessary, just like it is with python on the PC.

Michael
- 3rd June 2021, 23:19
Ok thanks. Yeah, I can't remember but it may have been a VB.net program that I needed to slow down the loop to keep it from hogging the cpu. I have the python script reading the PIC, so I may take out the pause I have there also and see. The python serial input command I think just sits there and waits anyway for valid data.

HenrikOlsson
- 4th June 2021, 07:47
On multi core / multi threaded CPU and programs commands like "PAUSE" and "SLEEP" etc usually releases "control" of the CPU so that that other process/threads can gain access to it for the durations of the "sleep".

With PBP that's simply not the case, PAUSE (just like almost all PBP commands) are blocking. In your case, the purpose of the PAUSE would be to "pace" the output, there's no other benefit or "good practice".