I'm trying to get a decimal number to show up from PC. Nothing shows up with the DEC in front of setemp, but if I take that DEC out I get the ascii characters.
Code:Include "modedefs.bas" INCLUDE "DT_INTS-14.bas" ' Base Interrupt System include "ReEnterPBP.bas" 'DEFINES----------------------------------------------------------------------- DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0 DEFINE HSER_CLROERR 1 ' Clear overflow automatically DEFINE HSER_SPBRG 25 ' 19200 Baud @ 8MHz, 0.16% SPBRGH = 0 BAUDCTL.3 = 1 ' Enable 16 bit baudrate generator define OSC 8 DEFINE ADC_BITS 8 ' Set A/D for 10-bit operation DEFINE ADC_CLOCK 3 ' Set A/D clock Fosc/8 DEFINE ADC_SAMPLEUS 50 ' Set A/D sampling time @ 50 uS 'Interrupt--------------------------------------------------------------------- ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler RX_INT, _Receive, PBP, yes endm INT_CREATE ; Creates the interrupt processor INT_ENABLE RX_INT ; enable external (INT) interrupts ENDASM 'SETUP REGISTERS--------------------------------------------------------------- TRISA=%001111 'RA0,RA1,RA2,RA3 inputs ANSEL=%00110000 'AN4,AN5 Analog In, rest digital ANSELH=$00 'All pins digital out TRISB=$00 'All pins output TRISC=%00000011 'All pins output,RC0,RC1 input CM1CON0.7=0 'Shut off comparators CM2CON0.7=0 'Shut off comparators ADCON0.7=0 'Right justify a/d result 'SETUP VARIABLES--------------------------------------------------------------- 'A/D on PORTC.0 'AN4 'A/D on PORTC.1 'AN5 Reset var PORTA.3 ' Reset chip LedR var PORTA.5 LedG var PORTB.6 Fanon var PORTC.2 tempc var PORTB.7 Menu0 var PORTA.2 ' Menu button Uptemp var PORTA.0 ' Raise temprature Dntemp var PORTA.1 ' Lower Temprature Menupdn var PORTB.4 ' Move through menu samples VAR WORD ' Multiple A/D sample accumulator up samples1 var word ' Multiple A/D sample accumulator down sample VAR BYTE ' Holds number of samples to take up sample1 var byte ' Holds number of samples to take down tempout VAR word ' Temperature storage up tempin var word ' Temperature storage down temp var word ' Set temprature setemp var word counter var byte counter1 var byte samples = 0 ' Clear samples accumulator on power-up samples1=0 ' Clear samples accumulator on power-up ;------------------------------------------------------------------------------ Getvalues: read 0,setemp if temp=255 then Defaultemp Defaultemp: setemp=90 write 0,setemp Start: hserout ["PUMP CONTROLLER",13,10] hserout ["VERSION 1.00",13,10] pause 3000 Main: gosub Getad gosub seroutPC if tempout>setemp then fan high ledr pause 500 low ledr pause 500 samples = 0 ' Clear old sample accumulator samples1=0 goto Main Fan: high fanon while tempout>setemp gosub getad gosub seroutPC samples = 0 ' Clear old sample accumulator samples1=0 wend low fanon goto main Getad: FOR sample = 1 TO 5 ' Take 5 samples ADCIN 4, tempout ' Read channel 0 into temp variable samples = samples + tempout ' Accumulate 10 samples PAUSE 250 ' Wait approximately 1/4 seconds per loop NEXT sample tempout = samples/5 tempout = tempout FOR sample1 = 1 TO 5 ' Take 5 samples ADCIN 5, tempin ' Read channel 0 into temp variable samples1 = samples1 + tempin ' Accumulate 10 samples PAUSE 250 ' Wait approximately 1/4 seconds per loop NEXT sample1 tempin = samples1/5 tempin = tempin return SeroutPC: hserout ["OUT Temp:",#tempout," DegF",13,10] hserout ["IN Temp:",#tempin," DegF",13,10] return Receive: hserin 500,Moveon,[dec setemp] hserout [dec setemp,13,10] 'high ledg 'pause 750 'low ledg 'pause 750 write 0,setemp Moveon: high ledg pause 750 low ledg pause 750 @ INT_RETURN




Bookmarks