I've never tried with a DEFINE OSC 20... but i think it's the main problem.
Look how i did it in mine. (config fuse as well)
and now
Code:
DoLow:
LOW PORTC.0
USBSERVICE
PAUSE 30
USBSERVICE
return
This example don't use instant interrupt, inserting a PAUSE and using On INTERRUPT GOTO might cause some problem for the USBSERVICE.
next point...i don't know what's happen if you use both HSER_BAUD and HSER_SPBRG together... Assuming HSER_SPBRG may override the HSER_BAUD, you have a big problem as your SPBRG value is way out of range @20MHZ... but good @8MHZ.
to have 2400 baud @20MHZ, you should use...
Code:
DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
DEFINE HSER_SPBRG 129 ' 2400 Baud @ 20MHz, 0.17%
DEFINE HSER_CLROERR 1 ' Clear overflow automatically
I do believe the HSER_CLROERR may help a little bit.
There's probably something else... i feel a bit lazy today
Last edited by mister_e; - 10th February 2007 at 18:03.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks