
Originally Posted by
Sam
Hi,
I'm trying to learn how to have serin wait for a string and then output a reply.
This is actually a continuation of my previous thread, I think I did have it working at one point then changed everything and now I'm lost. I've read the manual and re read it and searched and tried many different ways but I can't seem to get it right. Please point me in the right direction. Please tell me what I'm doing wrong.
Here is a test routine I'm trying to learn from:
'12F675
_CONFIG
_INTRC
_OSC
_NOCLKOUT
_WDT_ON
_PWRTE_ON
_MCLRE_OFF
_BODEN_ON
DEFINE OSCCAL_1K 1
INCLUDE "modedefs.bas"
TX_Pin VAR GPIO.0 'To DB9 RX pin 2
RX_Pin VAR GPIO.1 'To DB9 TX pin 3
TRISIO.0 = 0 'Set GPIO.0 to output.
TRISIO.1 = 1 'Set GPIO.1 to input
ANSEL = 0 'disable ADCs
CMCON = 7 'disable comparator
MyText VAR BYTE [5]
tx_pin = 0 'inverted mode idle state
MyText[0]="H"
MyText[1]="E"
MyText[2]="L"
MyText[3]="L"
MyText[4]="O"
Pause 100 'OSC settle time...
loop:
SerOut tx_pin,N9600,["Waiting for ",MyText,13,10]
SerIn rx_pin,N9600,[STR MyText]
SerOut tx_pin,N9600,["I GOT IT...",10,13]
GoTo loop
Thanks for any help
Hi Sam, I tried to compile your code and that failed.
Looking at the code posted, and really not all that familiar with arrays,
I think you need to use serin2 as listed below, It compiles anyway.
Code:
__CONFIG
_INTRC
_OSC
_NOCLKOUT
_WDT_ON
_PWRTE_ON
_MCLRE_OFF
_BODEN_ON
DEFINE OSCCAL_1K 1
INCLUDE "modedefs.bas"
TX_Pin VAR GPIO.0 'To DB9 RX pin 2
RX_Pin VAR GPIO.1 'To DB9 TX pin 3
TRISIO.0 = 0 'Set GPIO.0 to output.
TRISIO.1 = 1 'Set GPIO.1 to input
ANSEL = 0 'disable ADCs
CMCON = 7 'disable comparator
MyText VAR BYTE [5]
tx_pin = 0 'inverted mode idle state
MyText[0]="H"
MyText[1]="E"
MyText[2]="L"
MyText[3]="L"
MyText[4]="O"
Pause 100 'OSC settle time...
loop:
SerOut2 tx_pin,N9600,["Waiting for ",STR MyText\5,13,10]
SerIn2 rx_pin,N9600,[STR MyText\5]
SerOut2 tx_pin,N9600,["I GOT IT...",10,13]
GoTo loop
That is about all I can do, let me know if it works
JS
Bookmarks