' TITLE: SERIAL_DEBUG_DEMO ' AUTHOR: JONATHAN WALKER ' DATE: JAN 06 2004 ' COMPANY I WISH... '************************************************************************************************ ' NOTES ' VERY SIMPLE PROGRAM TO DEMONSTATE THE USE OF THE SERIAL DEBUG TOOL ' DISCONNECT THE LCD FROM THE PROTON+ DEVELOPMENT BOARD ' LOAD SERIAL DEBUG TOOL WITH PROTON_DEMO.TXT INCLUDE "PROTON_4.INC" TRISB = %00001111 ' ONLY RB0 IS INPUT TRISD = %00000000 DIM BYTEIN AS BYTE DIM LOCATION AS BYTE DIM WRITEVAL AS BYTE DELAYMS 600 ' WAIT FOR PICMICRO TO STABILISE CLEAR ' CLEAR ALL RAM RECEIVE: WHILE 1 = 1 ' CREATE AN INFINITE LOOP HRSIN {5000, TIMEOUT}, BYTEIN ' RECEIVE A BYTE SELECT BYTEIN ' DECODE RECEIVED BYTE CASE "1" HRSIN BYTEIN ' GET SERIAL BYTE MOVF BYTEIN,W ' LOAD INTO WORKING REGISTER BSF STATUS,RP0 ' PAGE 2 MOVWF FSR ' LOAD RECEIVED BYTE INTO FSR MOVF INDF,W ' GET DATA POINTED TO BY FSR INTO WORKING REG BCF STATUS,RP0 ' BACK TO PAGE 0 MOVWF BYTEIN ' TRANSFER W TO HOLDING REGISTER HRSOUT BIN8 BYTEIN ' SEND OUT DATA IN BINARY FORMAT CASE "0" HRSIN BYTEIN ' GET SERIAL BYTE (WILL BE IN PAGE0 IN THIS PROGRAM) MOVF BYTEIN,W ' LOAD INTO WORKING REGISTER MOVWF FSR ' LOAD RECEIVED BYTE INTO FSR MOVF INDF,W ' GET DATA POINTED TO BY FSR INTO WORKING REG' MOVWF BYTEIN ' TRANSFER W TO HOLDING REGISTER HRSOUT BIN8 BYTEIN ' SEND OUT DATA IN BINARY FORMAT CASE "W" HRSOUT CSTR TEXT1 ' SEND OUT REQUEST FOR LOACTION HRSIN LOCATION ' RECEIVE LOCATION HRSOUT CSTR TEXT2 ' SEND OUT REQUEST FOR WRITEVAL HRSIN WRITEVAL ' RECEIVE WRITEVAL MOVF LOCATION,W ' GET LOACTION INTO WORKING MOVWF FSR ' WRITE LOCATION VALUE TO FSR MOVF WRITEVAL,W ' GET WRITEVAL INTO WORKING MOVWF INDF ' LOAD WRITEVAL DATA INTO LOACTION POINTED BY FSR CASE "C" COMF PORTD ' COMPLIMENT PORTD CASE "J" HRSOUT CSTR TEXT3 ' SEND OUT TEXT CASE "X" PORTD = RANDOM ' PORTD RANDOM CASE ELSE HRSOUT CSTR TEXT4 ' SEND OUT TEXT END SELECT WEND ' CLOSE THE LOOP TIMEOUT: GOTO RECEIVE ' ENTER CODE HERE FOR TIMEOUT TEXT1: CDATA "ENTER PAGE0 LOCATION IN HEX",0 TEXT2: CDATA "ENTER WRITE VALUE IN HEX",0 TEXT3: CDATA "(C) JON WALKER 2004",0 TEXT4: CDATA "CMD NOT RECOGNISED",0 STOP ' AND STOP HERE UNTIL RESET PRESSED