Why would you call exit(0)? Where do you intend to return from the program flow? In most embedded system (well, with the OS-less ones) exiting from the main does not make sense. What compilers do with these code is either: 1. Call the main again 2. or... Call the Init/Startup _and_then_ the Main again 3. or... Go to an endless loop halting the MCU You should check your reference manual for this and see the disassembly what is going on. So for example you start sending the text, you might not waiting till the entire text had been sent over, but you exit -- then your code re-spawns and you start with the port/module initialization dropping the UART buffer or even stopping the transmittion in the middle with chunk bits already sent over... Tamas On Fri, Sep 25, 2009 at 12:42 PM, Quintin Beukes wrote: > Hey, > > I have noticed that when I execute exit(0) too many times, and then > writing to the serial port the data doesn't get to the other side > correctly. > > I for instance send the string "HAS 0", and then the other side will > sometimes receive it correctly, and sometimes as "HA 0", or "HASHAS > 0", or "HAS 0 HAS 0", or "HAHAS 0", etc. > > This can be reproduced everytime by exiting exit(0), letting it > reboot, executing again, about 10-20 times. Then it starts writing > data in this way. > > It's not really something that happens in production, but still, why > would it do this? It happens with all models I've tried it with (all > being 18Fxxxx) > > Quintin Beukes > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- http://www.mcuhobby.com -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist