Folks,
I’m struggling with a small PIC12F675 program which uses 3x analog inputs, 1x digital I/P, 1x digital O/P, and 1x serial O/P from a software UART.
I’m using an existing PCB, the analogs must be AN1,2, and 3, the DI is fixed at GP3.
The DO and serial OP can be either GP0 or GP5.
My problem is with pin 7, GP0. Something seems to override my program. I’m suspecting the comparator isn’t correctly disabled but cannot find the answer in the chip data sheets or the PIC midrange manual.
If I use GP0 for the serial output, I see pulses on the pin but my terminal doesn’t show the characters. GP5 works fine and follows the state of GP3.
If I swap GP0 and 5, so the serial data is on GP5, I see the transmitted text on the terminal and if the DI is held on I see GP0 pulsing with my logic probe.
Finally , if I put an AllDigital statement at the start of the program, the DO and serial OP work on GP0 and GP5.
So it seems like something related to the analog inputs or comparator are conflicting with GP0.
The code I'm using to find the problem follows.
Cheers
Malcolm
'For simulation, REM out for final program
Define SIMULATION_WAITMS_VALUE = 0
Define SEROUT_DELAYUS = 5000
'AllDigital
Symbol ser_out = GPIO.0
Symbol dig_op = GPIO.5
Symbol dig_ip = GPIO.3
Dim x_ai As Word
Dim y_ai As Word
Dim z_ai As Word
Define ADC_CLOCK = 3
Define ADC_SAMPLEUS = 50
ConfigPin ser_out = Output
ConfigPin dig_op = Output
ConfigPin dig_ip = Input
'Enable the ADC
ADCON0.ADON = True
'set Vref to Vdd
ADCON0.VCFG = False
'Disable the comparator in PIC12F675
cmcon.CM0 = 1
cmcon.CM1 = 1
cmcon.CM2 = 1
start:
Adcin 1, x_ai
Adcin 2, y_ai
Adcin 3, z_ai
Serout ser_out, 9600, "x :", #x_ai, CrLf
Serout ser_out, 9600, "y :", #y_ai, CrLf
Serout ser_out, 9600, "z :", #z_ai, CrLf
dig_op = dig_ip
Goto start
End
I’m struggling with a small PIC12F675 program which uses 3x analog inputs, 1x digital I/P, 1x digital O/P, and 1x serial O/P from a software UART.
I’m using an existing PCB, the analogs must be AN1,2, and 3, the DI is fixed at GP3.
The DO and serial OP can be either GP0 or GP5.
My problem is with pin 7, GP0. Something seems to override my program. I’m suspecting the comparator isn’t correctly disabled but cannot find the answer in the chip data sheets or the PIC midrange manual.
If I use GP0 for the serial output, I see pulses on the pin but my terminal doesn’t show the characters. GP5 works fine and follows the state of GP3.
If I swap GP0 and 5, so the serial data is on GP5, I see the transmitted text on the terminal and if the DI is held on I see GP0 pulsing with my logic probe.
Finally , if I put an AllDigital statement at the start of the program, the DO and serial OP work on GP0 and GP5.
So it seems like something related to the analog inputs or comparator are conflicting with GP0.
The code I'm using to find the problem follows.
Cheers
Malcolm
'For simulation, REM out for final program
Define SIMULATION_WAITMS_VALUE = 0
Define SEROUT_DELAYUS = 5000
'AllDigital
Symbol ser_out = GPIO.0
Symbol dig_op = GPIO.5
Symbol dig_ip = GPIO.3
Dim x_ai As Word
Dim y_ai As Word
Dim z_ai As Word
Define ADC_CLOCK = 3
Define ADC_SAMPLEUS = 50
ConfigPin ser_out = Output
ConfigPin dig_op = Output
ConfigPin dig_ip = Input
'Enable the ADC
ADCON0.ADON = True
'set Vref to Vdd
ADCON0.VCFG = False
'Disable the comparator in PIC12F675
cmcon.CM0 = 1
cmcon.CM1 = 1
cmcon.CM2 = 1
start:
Adcin 1, x_ai
Adcin 2, y_ai
Adcin 3, z_ai
Serout ser_out, 9600, "x :", #x_ai, CrLf
Serout ser_out, 9600, "y :", #y_ai, CrLf
Serout ser_out, 9600, "z :", #z_ai, CrLf
dig_op = dig_ip
Goto start
End