I am trying to use serial comms to a PC for the first time. I am using a known good PCB from another project which has a MAX 232 chip for the RS232 I/O. The processor is a 17C756A running at 10Mhz and I am using the Serial communicator in Micro Code Studio + to see what coming out of the port. I am trying to use 2400 Baud 8N1 (which serial communicator is set up to) for no other reason than it was the first one I thought of, but I have tried others. Basically the project is a Temperature Data Logger, which will have 8 inputs and as each sensor is read in turn, squirts the value read out of the Logger to a PC, most probably running Excel. I have used ADCIN before on another project and I know I can get that to work (if its wrong in the example shown, don't worry about that I will sort it later) my problem now is to get the value stored in variable B3, out of the serial port and into my PC, at the moment, serial communicator shows characters coming out, but they are garbage and some of the time the characters change. I have forced B3 to a known value for testing purposes, so B3 should be reading as 123. I have calculated the SPBRG value from the Microchip Data Sheet AN774 as being (10000000 / (64 x 2400 =153600) -1 =64.104166. There is no High Speed option on the PIC17C756A according to the data sheet, so BRGH = 0. Incidentaly the LCD display is working fine.
Here is a listing from what I have so far:-
'FW1-0DLV1-0 09/07/2K6
'Was MCV2-2FW1-2
'A4 P43 =RS232 RX-1 Input
'A5 P42 =RS232 TX-1 Output
'B0 P59 ="Serial" LED Output
'B1 P58 ="Coin" LED Output
'B2 P54 ="Error" LED Output
'B7 P48 =Beeper Output
'D0 P11 =Display D0 Output
'D1 P10 =Display D1 Output
'D2 P9 =Display D2 Output
'D3 P8 =Display D3 Output
'D4 P4 =Display D4 Output
'D5 P6 =Display D5 Output
'D6 P5 =Display D6 Output
'D7 P4 =Display D7 Output
'E0 P12 =Display RS Output
'E1 P13 =Display R/W Output
'E2 P14 =Display E Output
'F0 P28 =AN4=Input
'F1 P27 =AN5=Input
'F2 P26 =AN6=Input
'F3 P25 =AN7=Input
'G0 P34 =AN3=Input
'G1 P33 =AN2=Input
'G2 P32 =AN1=Input
'G3 P31 =AN0=Input
B0 VAR BYTE
B1 VAR BYTE 'General Purpose Counter
B2 VAR BYTE 'Value Of ADC Channel
B3 VAR BYTE 'ADC Channel Value after processing
B21 VAR BYTE
B22 VAR BYTE
B26 VAR BYTE
clear
TRISB = %01100000 'Sets Pins to Input or Output
TRISC = %11111100 'Sets Pins to Input or Output
TRISD = %00000000 'Sets Pins to Input or Output
TRISE = %11111000 'Sets Pins to Input or Output
TRISF = %01011111 'Sets Pins to Input or Output
TRISG = %11111111 'Sets Pins to Input or Output
PORTE.1 = 0
PORTB.7 = 1
DEFINE OSC 12
DEFINE LCD_DREG PORTD
DEFINE LCD_DBIT 0
DEFINE LCD_RWREG PORTE
DEFINE LCD_RWBIT 1
DEFINE LCD_RSREG PORTE
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTE
DEFINE LCD_EBIT 2
DEFINE LCD_BITS 8
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50
ADCON1 = %11101111
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 50
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 20h
DEFINE HSER_BRGH 0
DEFINE HSER_SPBRG 64
DEFINE HSER_CLOERR 1
GoTo STARTUP
STARTUP:
LCDOut $FE,1,"Data Logger V1.0"
LCDOut $FE,$C0,"Reseting "
PortB.0 = 1
PortB.1 = 1
PortB.2 = 1
Pause 100
PORTB.0=0 : PORTB.1=0 : PORTB.2=0 : PORTB.3=0 : PORTB.4=0 : PORTB.7=1
PORTC.0=0
PORTF.5=0 : PORTF.7=0
GOTO MAIN
MAIN: LCDOut $FE,1,"Press button "
LCDOut $FE,$C0,"to start logging"
PAUSE 100
'IF PORTC.2 = 0 Then START
Goto start 'MAIN
START: SOUND PORTB.7,[127,5]
GOTO Sens1
SENS1: ADCON0 = %00010001
ADCON1 = %11101010
ADCIN 1, B2 'Read Value of RTC
B3 = B2 >> 2
ADCON1 = %11101110
ADCON0.0=0
PAUSE 100
LCDOut $FE,1,"Sensor 1 = ",#B3
PortB.0 = 1
PAUSE 50
Portb.0 = 0
B3 = 123 'Set B3 to known value for testing Port
HSEROUT [DEC B3,13,10]
PAUSE 100
GOTO SENS1
END
Here is an example of what comes out (using Serial Communicator)
À0>0ð0~€0>0ð0>À0>0ð0>À0>0ð0>À0>0ð0>À0>0ð0>À0>0ð0>À0>0ð0>Àp~0ð0>À0>0ð0>À0>pð0>À0>0ð0>À0>0ð0~€0>0ð0>À0>0ð0>À0>0ð0>À0>0ð0>À0>0ð0>À0>0ð0>À0>0ð0>Àp~0ð0>À0>0ð0>À0>pð0>À0>0ð0>À0>0ð0~€0>0ð0>À0>0ð0>À0>0ð0>À0>0ð0>À0>0ð0>À0>0ð0>À0>0ð0>Àp~0ð0>À0>0ð0>À0>pð0>À0>0ð0>À0>0ð0~€0>0ð0>À0>0ð0>À0>0ð0>À0>0ð0>À0>0ð0>À0>0ð0>À0>0ð0>Àp~0ð0>À0
Would somebody please help me, I've done all the usual "try everything/anything" " late nights" "
Regards Mark Scotford
[email protected] (remove the X to reply)
Bookmarks