> -----Original Message----- > From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] On Behalf > Of Matt Rhys-Roberts > Sent: 01 March 2010 11:12 > To: Microcontroller discussion list - Public. > Subject: [PIC] C18 & PIC18F8627: first printf() destroys SPBRG setting > > I'm using printf() to talk directly to EUSART1, without going via the > usart.h library. We decided to avoid this library for now in order to > keep code as direct and simple as possible. > > printf() appears to call code in file > c:\MCC18\src\pmc_common\USART\_usartpc.asm , which clears SPBRG when > first run, causing serial timing to fail. However, if I manually re-set > SPBRG in the watch window, it remains uncleared and serial transmission > continues happily. > > Q1) Any idea why this has to happen, and what could/should be done about > it? > Q2) Does anyone have any optimal examples of setting up printf() > explicitly without using usart.h ? I would suggest that since you are using the printf library function, it's probably assuming you are also using the supplied functions to open the USART which is OpenUSART() IIRC. If you want to keep code simple and direct, then using printf is not a good start, it's probably one of the most complex functions in the standard C library. Regards Mike ======================================================================= This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. ======================================================================= -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist