Hi,
The dummy HSEROUT just forces a "proper" setup of the USART, it can just as well be done manually. When your inline assembly didn't work it was missing something in USART setup. (Been there...)
Using Steves excellent tool (PICMultiCalc (thanks again Steve!)) suggests the following for 31250baud @ 20MHz:Try that and remove the DEFINE HSERBAUD 31250 and see what happends. The weird thing is that since you say it works perfectly when you send continously the baudrate "must" be correct and adding the button check really shouldn't matter.Code:DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0 DEFINE HSER_CLROERR 1 ' Clear overflow automatically DEFINE HSER_SPBRG 39 ' 31250 Baud @ 20MHz, 0,0% SPBRGH = 0 BAUDCON.3 = 1 ' Enable 16 bit baudrate generator




Bookmarks