Actually, i do have 3 interrupts in this program. Maybe SEROUT is getting interrupted and thats messing with the data.
I'm gonna try disabling the interrupts while I run SEROUT... Not the best long term solution as It wouldnt be good to miss one of those interrupt events, but its worth a try to see if thats whats causing my problem.
"I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams
I tried to test the interrupt theory with a simple GIE=0 before SEROUT and GIE=1 after it, but disabling the interrupts makes my program do unexpected things and makes it impossible to test. But i'd say its a high probability that the interrupts are the issue.
So I guess i'll have to stick with the hardware USART and, as skimask suggested, multiplex its output.
*edit*: Using ASM interrupts as timing is important.
Last edited by Kamikaze47; - 3rd March 2008 at 15:24.
"I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams
I've used serout and debug out to run to two different Double-Talk boards at 9600 baud, both performed perfectly, so I'd have to say that you're right, it's probably the interrupts. I tried it using two different LabX-Usb boards, with 18f4550's, with a DEFINE OSC 48. The boards have 20 Mhz crystals, and the oscillator selection is for HS_PLL.
Jerry.
If your oscilloscope costs more than your car...
My serial data errors all went away as soon as I started presetting the data line before transmission.
For example, RS-232 defines the IDLE or MARK state to be negative volts at the RS-232 connector. That means positive volts at the PIC before the MAX232 inverter.
Try something like
HIGH TxData
pause 2
Serout/Serout2/Hserout your message.
It works for me.
HTH
BrianT
BrianT: I previously tried a non-true driven mode and tied the line to +5 with a 10k resistor, which did not help reliability.
b1arrk5: Yep, in the end I did manage to test it with my interrupts disabled, and it worked, so thats the issue. Disabling the interrupts while I send isn't an option, so no software serial comms for me I guess.
"I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams
Ok, i'm looking at the best way of multiplexing the hardware USART's output and this is what I have come up with.
- Use IC with 4 OR gates (only using 2, but they come with 4).
- Gate 1: Input1=USART, Input2=A PIC I/O Pin, Output=One of the serial outputs
- Gate 2: Input1=USART, Input2=Another PIC I/O Pin, Output=Another serial output
- Use software so that only 1 of the I/O pins is ever high at a time
I know I could use a NOT gate which would allow me to use only 1 I/O Pin, but i'd rather use another I/O pin than add another IC.
If anyone can see how this can be done better (and still only using the PIC + 1 IC), feel free to share.
"I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams
Bookmarks