* XML ENCODED HC11 inputs *The program scans digital and analog inputs, then sends XML encoded data using the RS232 port once per second. *Copyright (C) 2002 Jason Low *This program is free software; you can redistribute it and/or *modify it under the terms of the GNU General Public License *as published by the Free Software Foundation; either version 2 *of the License, or (at your option) any later version. *This program is distributed in the hope that it will be useful, *but WITHOUT ANY WARRANTY; without even the implied warranty of *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *GNU General Public License for more details. *You should have received a copy of the GNU General Public License *along with this program; if not, write to the Free Software *Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *************** * EQUATES * *************** RAMBS EQU $C600 start of ram REGBS EQU $1000 start of registers ROMBS EQU $F800 start of rom PORTA EQU REGBS+$00 port A PORTC EQU REGBS+$03 port C ADR1 EQU $1031 ADR2 EQU $1032 ADR3 EQU $1033 ADR4 EQU $1034 BAUD EQU REGBS+$2B sci baud reg SCCR1 EQU REGBS+$2C sci control1 reg SCCR2 EQU REGBS+$2D sci control2 reg SCSR EQU REGBS+$2E sci status reg SCDAT EQU REGBS+$2F sci data reg DDRC EQU REGBS+$07 ADCTL EQU $30 DFLOP EQU $4000 OPT EQU $39 ORG $0000 STATION RMB 1 ELEMENT RMB 1 TYPE RMB 1 VALUE_0 RMB 1 VALUE_1 RMB 1 VALUE_2 RMB 1 ADTMR RMB 1 ***************** * ROM starts here * ***************** ORG $FFFE ;initialize reset vector FDB $F800 ;to start at f800 ORG ROMBS START LDS #$FF CLR DDRC LDAA #$00 STAA DFLOP JSR ONSCI JSR INIAD LDAA #$3D STAA ADTMR LDAA #$35 * STATION # STAA STATION MAIN LDAA ADTMR INCA STAA ADTMR CMPA #$3B BLO STEP JSR ADREAD LDAA #$00 STAA ADTMR STEP JSR XMLST * OUTPUT ASCII '*' ************************** *** ANALOG DATA ************************** LDAA #$6E * DATA TYPE NUMBER ASCII n STAA TYPE LDAA #$30 * DATA ELEMENT STAA ELEMENT LDAA ADR1 * ANALOG PORT 1 JSR HEX_DEC JSR XMLOUT * OUTPUT ASCII LDAA #$31 * DATA ELEMENT STAA ELEMENT LDAA ADR2 * ANALOG PORT 2 JSR HEX_DEC JSR XMLOUT * OUTPUT ASCII LDAA #$32 * DATA ELEMENT STAA ELEMENT LDAA ADR3 * ANALOG PORT 3 JSR HEX_DEC JSR XMLOUT * OUTPUT ASCII LDAA #$33 * DATA ELEMENT STAA ELEMENT LDAA ADR4 * ANALOG PORT 4 JSR HEX_DEC JSR XMLOUT * OUTPUT ASCII ************************** *** BIT DATA ************************** LDAA #$30 STAA VALUE_0 STAA VALUE_1 STAA VALUE_2 LDAA #$0 STAA VALUE_0 LDAA #$62 * DATA TYPE BIT ASCII b STAA TYPE LDAA #$30 STAA ELEMENT LDAA PORTC ANDA #%00000001 * MASK LSB ORA #%00110000 * ASCII CONVERSION STAA VALUE_0 JSR XMLOUT * OUTPUT ASCII LDAA #$31 STAA ELEMENT LDAA PORTC RORA ANDA #%00000001 * MASK LSB ORA #%00110000 * ASCII CONVERSION STAA VALUE_0 JSR XMLOUT * OUTPUT ASCII LDAA #$32 STAA ELEMENT LDAA PORTC RORA RORA ANDA #%00000001 * MASK LSB ORA #%00110000 * ASCII CONVERSION STAA VALUE_0 JSR XMLOUT * OUTPUT ASCII LDAA #$33 STAA ELEMENT LDAA PORTC RORA RORA RORA ANDA #%00000001 * MASK LSB ORA #%00110000 * ASCII CONVERSION STAA VALUE_0 JSR XMLOUT * OUTPUT ASCII LDAA #$34 STAA ELEMENT LDAA PORTC RORA RORA RORA RORA ANDA #%00000001 * MASK LSB ORA #%00110000 * ASCII CONVERSION STAA VALUE_0 JSR XMLOUT * OUTPUT ASCII LDAA #$35 STAA ELEMENT LDAA PORTC RORA RORA RORA RORA RORA ANDA #%00000001 * MASK LSB ORA #%00110000 * ASCII CONVERSION STAA VALUE_0 JSR XMLOUT * OUTPUT ASCII LDAA #$36 STAA ELEMENT LDAA PORTC RORA RORA RORA RORA RORA RORA ANDA #%00000001 * MASK LSB ORA #%00110000 * ASCII CONVERSION STAA VALUE_0 JSR XMLOUT * OUTPUT ASCII LDAA #$37 STAA ELEMENT LDAA PORTC RORA RORA RORA RORA RORA RORA RORA ANDA #%00000001 * MASK LSB ORA #%00110000 * ASCII CONVERSION STAA VALUE_0 JSR XMLOUT * OUTPUT ASCII JSR XMLEND * OUTPUT ASCII '$' JSR TIME_DY JMP MAIN XMLST LDAA #$2A * OUTPUT ASCII '*' JSR OUTSCI RTS XMLOUT LDAA #$3C * ASCII < JSR OUTSCI LDAA TYPE * TYPE JSR OUTSCI LDAA #$2C * ASCII , JSR OUTSCI LDAA STATION * STATION JSR OUTSCI LDAA #$2C * ASCII , JSR OUTSCI LDAA ELEMENT * ELEMENT JSR OUTSCI LDAA #$3E * ASCII > JSR OUTSCI OUT2 LDAA VALUE_2 * VALUE_2 CMPA #$30 BLE OUT1 JSR OUTSCI BRA OUT_11 OUT1 LDAA VALUE_1 * VALUE_1 OUTPUT VALUE_1 IF VALUE_2 IS 0 CMPA #$30 BLE OUT0 OUT_11 LDAA VALUE_1 * VALUE_1 OUTPUT VALUE_1 IF VALUE_2 IS NOT 0 JSR OUTSCI OUT0 LDAA VALUE_0 * VALUE_0 JSR OUTSCI LDAA #$3C * ASCII < JSR OUTSCI LDAA #$2F * ASCII / JSR OUTSCI LDAA TYPE * TYPE JSR OUTSCI LDAA #$2C * ASCII , JSR OUTSCI LDAA STATION * STATION JSR OUTSCI LDAA #$2C * ASCII , JSR OUTSCI LDAA ELEMENT * ELEMENT JSR OUTSCI LDAA #$3E * ASCII > JSR OUTSCI RTS XMLEND LDAA #$24 * ASCII '$' END OF DATA BSR OUTSCI LDAA #$0D * ASCII CR BSR OUTSCI LDAA #$0A * ASCII LF BSR OUTSCI RTS **Time Delay* TIME_DY LDX #$0004 DELAY LDY #$ffff TDB DEY BNE TDB DEX BNE DELAY RTS H_A TAB LSRA LSRA LSRA LSRA ANDA #%00001111 * MASK MSN ORA #%00110000 CMPA #$39 BLE LEAST ADDA #$07 STAA VALUE_1 LEAST TBA ANDA #%00001111 * MASK LSN ORA #%00110000 CMPA #$39 BLE RETURN ADDA #$07 STAA VALUE_0 RETURN RTS HEX_DEC TAB LDAA #$30 STAA VALUE_0 STAA VALUE_1 STAA VALUE_2 HEX_1 CMPB #$0 BEQ HEX_END LDAA VALUE_0 INCA CMPA #$3A BEQ VAL_1 STAA VALUE_0 BRA LOOPDEC VAL_1 LDAA #$30 STAA VALUE_0 LDAA VALUE_1 INCA CMPA #$3A BEQ VAL_2 STAA VALUE_1 BRA LOOPDEC VAL_2 LDAA #$30 STAA VALUE_1 LDAA VALUE_2 INCA STAA VALUE_2 LOOPDEC DECB BRA HEX_1 HEX_END RTS ********** * OUTSCI() - Output A to sci. ********** OUTSCI TST SCSR BPL OUTSCI STA SCDAT RTS ********** * ONSCI() - Initialize the SCI for 9600 * baud at 8 MHz Extal. ********** ONSCI LDAA #$30 STAA BAUD baud register LDAA #$00 STAA SCCR1 LDAA #$0C STAA SCCR2 enable RTS ****** Inilize the a/d converter ************************************** INIAD LDX #REGBS BSET OPT,X %10000000 BCLR OPT,X %01000000 RTS ****** Update the a/d converter registers ****************************** ADREAD PSHX LDX #REGBS LDAA #%10010000 STAA ADCTL,X ADREAD1 LDAA ADCTL,X ANDA #%10000000 BEQ ADREAD1 PULX RTS ************************************************************************