
Originally Posted by
Andre_Pretorius
I am trying to read 4 Analog inputs with a pic and deliver them out on a hardware serial port. For some reason nothing happens. I am new to the 16F877 any help would be apreciated.
INCLUDE "MODEDEFS.BAS"
INCLUDE "ANSI.INC"
DEFINE OSC 20 ' Define crystal as 20Mhz
'*Serial port Setup 9600 8N1*
DEFINE HSER_BAUD 9600 ; 9600 Baud
DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
DEFINE HSER_CLROERR 1 ; Clear overflow automatically
'Define ACDIN parameters
Define ADC_BITS 10 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source ( 3 = RC )
DEFINE ADC_SAMPLEUS 50 ' Set sampling time to micro-seconds
'This Part set PORTA 0-5 an analog inputs
TRISA = %00011111 'set PORTA 0-5 as inputs
ADCON1 = %10000000 'Right justify output of ADC use vss and vdd as ref.
ADCON0 = %11100000 'FRC (clock derived from a dedicated internal oscillator)
TRISC = %10000000 'RC7 as RX(input) rest as output
V1 var WORD
V2 var WORD
V3 var WORD
V4 var WORD
Main:
@ ClearScr ; Clear Screen
ADCIN 0,v1
ADCIN 1,v2
ADCIN 2,v3
ADCIN 3,v4
HSEROUT [DEC v1,13,10]
HSEROUT [DEC v2,13,10]
HSEROUT [DEC v3,13,10]
HSEROUT [DEC v4,13,10]
goto main
Try Add : DEFINE HSER_SPBRG 129
also do not see any config fuse settings, I am at work so have no access to data sheets, does this chip have ansel ?
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Bookmarks