I'm using a serial lcd at 9600 baud and if i move the lcd to another pin and drive it with a software serial routine that gets corrupted by the interrupt instead of the data out.
If i can break the data I'm sending via the software serial routine down to byte size chunks the effect on my pwm is negligible. I can disable the interrupt for one byte at a time and use a subroutine to transmit it from some sort of ram buffer.
I had thought of using the hserout for both devices by using a switch like a HCT4053 to change it from one to the other but my pcb won't allow that.
I quite like that idea charles but when I'm transmitting data the lcd will display it as well which i don't want.
I was thinking you were driving the LCD in 4 bit parallel mode. In your case, I would run my 16F88 at 20MHz and use DEBUGOUT at 57600 baud for one of the serial ports. DEBUGOUT has way lower overhead than SEROUT2. It takes less time to set up for the write and also allows you to run at
higher baud rates than SEROUT2.
Charles Linquist
And before I shut up tonight, with a little ASM, you wouldn't have to turn off interrupts at all.
Just download and include one of the (fairly) easy to find RS-232 ASM routines. Run it at 57600 baud. Set up a one-byte buffer. Have the PWM ISR check for a "buffer full" flag. If set, it jumps to the RS-232 routine and sends the byte, and when that routine is done sending the byte, it clears the "buffer full" flag. Since your PWM ISR is running at 2Khz, you have 500uSec between interrupts. But you can send a byte (at 57600) in 180uSec. Plenty of time.
Your main program loop could then just check the buffer full flag. If it wasn't set, it would write a byte the the buffer.
No stopping interrupts, and no corrupted data.
Charles Linquist
Thanks for the ideas all. What is the max baud rate for debug? can it do 115200? It seems to compile ok i could not find a supported baud rate list.
Depends on the OSC speed.
http://www.picbasic.co.uk/forum/show...4356#post34356
Dave
Always wear safety glasses while programming.
Can't you use hardware PWM?
Bookmarks