ozarkshermit
- 31st March 2009, 16:24
Howdy
I've fought this long enough - now am asking for help.
What I have is a serial LCD backpack with a keypad interface as well. Using a PIC 16F870 . That all works fine.
Sending serial characters, custom characters, etc to the LCD works fine.
The problem I have is getting data back from the keypad.
How it works is a request is sent to the keypad using a SEROUT2 command, ($FE,$1B,) an interrupt is returned, (active low), and after it goes high the key number is returned serially. This all works, I have attached a screen shot of the data transmissions from my logic analyzer.
What I can't get to work is the SERIN2 to actually get the key value back in.
As I said, the serial data (byte) is coming back, but the SERIN2 just "hangs", and never brings the data in.(must not see it) I tried using a timeout and label in the SERIN2 statement, but that was counter productive, 'cause the data was not being seen anyway.
here is a short code segment
serout2 Tx,84, [$FE,$1B] ' request for key data (code for this backpack)
pauseus 500
serin2 Rx,84,[key] ' get the key pressed from keypad buffer
pauseus 500
serout2 Tx, 84, [$FE,$0C,1,0,#key] 'display it on LCD line 2, position 1
key jas been defined as a byte variable
Tx is PORTC.7 and Rx is PORTC.6
The interrupt is returned to PORTC.5
4 Mhz oscillator is defined
The attached screen shot from my logic analyzer shows the interrupt line, data request, and serial data returned. A decimal "9" is what is returned in this case.
I've tried several variations of the SERIN2 command ( even tried SERIN with the "modedefs.bas" included )
Should I be trying to receive the data in an interrupt routine? That does not seem necessary - - -
Something simple, I'm sure - but I am stumped.
Thanks
Ken
I've fought this long enough - now am asking for help.
What I have is a serial LCD backpack with a keypad interface as well. Using a PIC 16F870 . That all works fine.
Sending serial characters, custom characters, etc to the LCD works fine.
The problem I have is getting data back from the keypad.
How it works is a request is sent to the keypad using a SEROUT2 command, ($FE,$1B,) an interrupt is returned, (active low), and after it goes high the key number is returned serially. This all works, I have attached a screen shot of the data transmissions from my logic analyzer.
What I can't get to work is the SERIN2 to actually get the key value back in.
As I said, the serial data (byte) is coming back, but the SERIN2 just "hangs", and never brings the data in.(must not see it) I tried using a timeout and label in the SERIN2 statement, but that was counter productive, 'cause the data was not being seen anyway.
here is a short code segment
serout2 Tx,84, [$FE,$1B] ' request for key data (code for this backpack)
pauseus 500
serin2 Rx,84,[key] ' get the key pressed from keypad buffer
pauseus 500
serout2 Tx, 84, [$FE,$0C,1,0,#key] 'display it on LCD line 2, position 1
key jas been defined as a byte variable
Tx is PORTC.7 and Rx is PORTC.6
The interrupt is returned to PORTC.5
4 Mhz oscillator is defined
The attached screen shot from my logic analyzer shows the interrupt line, data request, and serial data returned. A decimal "9" is what is returned in this case.
I've tried several variations of the SERIN2 command ( even tried SERIN with the "modedefs.bas" included )
Should I be trying to receive the data in an interrupt routine? That does not seem necessary - - -
Something simple, I'm sure - but I am stumped.
Thanks
Ken