Serial Input by Bit Banging

rodmcm

Member
Amazing this hobby isnt it, first you learn to light up an LED and from then on its LCDs, serial inputs and now bit banging.
Based on a previous question I have abandoned my attempts to run a LCD from a serial input via interrupts. I thought about the spiin command, but even though I am using an 18X the compiler will not accept it . Is it an error in the programmer? So the next is to try bit banging. Can anyone advise whether an 18X will be fast enough to use this technique on any digit input recieving serial data.
 

moxhamj

New Member
Might be a bit beyond the 18X. But could you pls explain this a bit more; "run a LCD from a serial input via interrupts"

What is driving what?

Personally, I've gone for the parallel LCD modules as they are only $13.50 including shipping on ebay for a 20x4 module. And 20x4 can display a lot of very useful information about what a program is up to.

But I'm almost certain the 18X can drive the serial LCD. Can you post a schematic by any chance?
 

rodmcm

Member
I have been experimenting with the serial input to an 18X running an LCD, which s fine, however using an interrupt and serin on a pin losses bits due to the slowness of the 18X and now want to try bit banging

Interrupt:
serin 2, N2400,ReadByte ' Reads into ReadByte from Pin 2
gosub SwapByte ' Swaps LB and UB
OutputByte = ReadByte ' Places Readbyte in OutputByte
rs=LCDData ' sets bit for data
gosub WriteToLCD ' Writes to LCD
SetInt %00000100,%00000100' resets interrupt
Return
 

hippy

Technical Support
Staff member
Bit-banging on a PICAXE will be slower than using SerIn and the PICAXE is probably not fast enough to capture 2400 baud data by bit-banging.
 

womai

Senior Member
Maybe it's just me, but I am still not sure WHAT exactly is not working. Is the Picaxe not receiving all the bytes because it spends too much time processing the received data and sending it to the LCD? And what exactly do you want to bit-bang? The serial receive (i.e. the data that now the Picaxe reads with serin) or the LCD drive (but that seems to be bit-banged anyway)?

If you could post the full code than I am sure we could figure out ways to make it faster. Also, did you try to increase the 18X's clock frequency to 8MHz? And/or could you go to a lower baud rate?

If the issue is that the Picaxe doesn't get into the interrupt routine fast enough, you could try adding a qualifier, i.e. instead of sending just the data byte, send a "marker string" followed by the data byte:

on the sender (assuming it is also a Picaxe):

serout 2, N2400, ($00, $00, $00, "LcD", my_data_byte) ' $00s trigger interrupt, "LcD" is the marker

on the receiver Picaxe:

serin 2, N2400, ("LcD"), my_received_data_byte ' will wait for "LcD" to be received and then read the next bute into the variable

Finally, another option could be to use a 28X1 instead, which can receive serial data in the background (and store it into the scratchpad RAM) while the main routine is busy processing the data and sending it to the LCD.

Wolfgang
 
Top