mtripoli
- 11th November 2013, 21:07
After banging on this thing for a few hours I'm beginning to think this device is really chewing gum with metal legs. ;) This is kindof' an odd device; its like a "PIC12Fxxx" but with a "PIC16Fxxx" designation, with built-in opamps (which is why I'm using it).
I'm simply trying to blink an LED. The outputs, across the board, seem to be set as inputs. The first question I have is, how does one set the TRISA on 12 bit devices? If I give it a TRISA command I get an error. Data sheet isn't much help; it refers to "TRISA, TRISB, TRISC". Despite that, I don't think that's the problem given that my LED is on PORTC.0...
As you can see in the code, PORTC.0 is an output, and I believe all the appropriate configuration bits are set properly. Comparators are off, A/D is off, OPAMPS are "on", ANSEL is configured. I know the part is running; I can see the clock out on the clock out pin (DIV/4). MCLR works as well. Just no output from anything. Can someone give this an eyeball and tell me what I've over-looked? Never had so much trouble with any device blinking an led...
BTW: I'm using the latest PBPX 3.0.7.4 with a U2 programmer running meProg v.4.51.
Thanks in advance,
Mike T.
'************************************************* ***************
'* Name : LED_000.BAS *
'************************************************* ***************
#CONFIG
__config _FOSC_INTRC_CLKOUT &_WDTE_OFF &_CP_OFF &_MCLRE_ON &_IOSCFS_4MHz &_CPSW_OFF &_BOREN_OFF &_DRTEN_OFF
#ENDCONFIG
DEFINE OSC 4
INCLUDE "modedefs.bas"
;ALIASES
PBTN VAR PORTA.0 ; INPUT - DIGITAL
; NOT USED VAR PORTA.1 ; OUTPUT - SET LOW
ANIN2 VAR PORTA.2 ; INPUT - ANALOG
; NOT USED VAR PORTA.3 ; OUTPUT - SET LOW
ANIN3 VAR PORTA.4 ; INPUT - ANALOG
OLED VAR PORTA.5 ; OUTPUT - DIGITAL
; OP2_MINUS VAR PORTB.4 ; INPUT - OPAMP
; OP2_PLUS VAR PORTB.5 ; OUTPUT - OPAMP
; NOT USED VAR PORTB.6 ; OUTPUT - DIGITAL
; NOT USED VAR PORTB.7 ; OUTPUT - DIGITAL
LED VAR PORTC.0 ; OUTPUT - DIGITAL
; NOT USED VAR PORTC.1 ; OUTPUT - DIGITAL
; OP2_OUT VAR PORTC.2 ; OUTPUT - ANALOG
; OP1_OUT VAR PORTC.3 ; OUTPUT - ANALOG
; NOT USED VAR PORTC.4 ; OUTPUT - DIGITAL
; NOT USED VAR PORTC.5 ; OUTPUT - DIGITAL
; OP1_MINUS VAR PORTC.6 ; INPUT - ANALOG
; OP1_PLUS VAR PORTC.7 ; INPUT - ANALOG
;PORT CONTROL REGISTERS
;PORTA
;TRISA = %00010101 ;HUH??????
TRISB = %00010000
TRISC = %11000000
; ANSEL
; 7 6 5 4 3 2 1 0
;RC.3 RC.2 RC.1 RC.0 RA.4 RA.2 RA.1 RA.0
ANSEL = %11001100
; INTCON CONTROL REGISTERS
INTCON0 = %00000000
INTCON1 = %00000000
; OPTION CONTROL REGISTER
OPTION_REG = %11000000
;ADC CONTROL REGISTERS
ADCON0 = %00000000 ; ADC DISABLED
; COMPARATOR CONTROL REGISTERS
CM1CON0 = %01000000 ; COMPARATORS OFF - BIT 3
CM2CON0 = %01000000
VRCON.7 = 0 ; VOLTAGE REFERENCE OFF
; OPAMP CONTROL REGISTER
OPACON = %00000011 ; OPAMPS ON
BLINK:
HIGH LED
PAUSE 500
LOW LED
PAUSE 500
GOTO BLINK
end
I'm simply trying to blink an LED. The outputs, across the board, seem to be set as inputs. The first question I have is, how does one set the TRISA on 12 bit devices? If I give it a TRISA command I get an error. Data sheet isn't much help; it refers to "TRISA, TRISB, TRISC". Despite that, I don't think that's the problem given that my LED is on PORTC.0...
As you can see in the code, PORTC.0 is an output, and I believe all the appropriate configuration bits are set properly. Comparators are off, A/D is off, OPAMPS are "on", ANSEL is configured. I know the part is running; I can see the clock out on the clock out pin (DIV/4). MCLR works as well. Just no output from anything. Can someone give this an eyeball and tell me what I've over-looked? Never had so much trouble with any device blinking an led...
BTW: I'm using the latest PBPX 3.0.7.4 with a U2 programmer running meProg v.4.51.
Thanks in advance,
Mike T.
'************************************************* ***************
'* Name : LED_000.BAS *
'************************************************* ***************
#CONFIG
__config _FOSC_INTRC_CLKOUT &_WDTE_OFF &_CP_OFF &_MCLRE_ON &_IOSCFS_4MHz &_CPSW_OFF &_BOREN_OFF &_DRTEN_OFF
#ENDCONFIG
DEFINE OSC 4
INCLUDE "modedefs.bas"
;ALIASES
PBTN VAR PORTA.0 ; INPUT - DIGITAL
; NOT USED VAR PORTA.1 ; OUTPUT - SET LOW
ANIN2 VAR PORTA.2 ; INPUT - ANALOG
; NOT USED VAR PORTA.3 ; OUTPUT - SET LOW
ANIN3 VAR PORTA.4 ; INPUT - ANALOG
OLED VAR PORTA.5 ; OUTPUT - DIGITAL
; OP2_MINUS VAR PORTB.4 ; INPUT - OPAMP
; OP2_PLUS VAR PORTB.5 ; OUTPUT - OPAMP
; NOT USED VAR PORTB.6 ; OUTPUT - DIGITAL
; NOT USED VAR PORTB.7 ; OUTPUT - DIGITAL
LED VAR PORTC.0 ; OUTPUT - DIGITAL
; NOT USED VAR PORTC.1 ; OUTPUT - DIGITAL
; OP2_OUT VAR PORTC.2 ; OUTPUT - ANALOG
; OP1_OUT VAR PORTC.3 ; OUTPUT - ANALOG
; NOT USED VAR PORTC.4 ; OUTPUT - DIGITAL
; NOT USED VAR PORTC.5 ; OUTPUT - DIGITAL
; OP1_MINUS VAR PORTC.6 ; INPUT - ANALOG
; OP1_PLUS VAR PORTC.7 ; INPUT - ANALOG
;PORT CONTROL REGISTERS
;PORTA
;TRISA = %00010101 ;HUH??????
TRISB = %00010000
TRISC = %11000000
; ANSEL
; 7 6 5 4 3 2 1 0
;RC.3 RC.2 RC.1 RC.0 RA.4 RA.2 RA.1 RA.0
ANSEL = %11001100
; INTCON CONTROL REGISTERS
INTCON0 = %00000000
INTCON1 = %00000000
; OPTION CONTROL REGISTER
OPTION_REG = %11000000
;ADC CONTROL REGISTERS
ADCON0 = %00000000 ; ADC DISABLED
; COMPARATOR CONTROL REGISTERS
CM1CON0 = %01000000 ; COMPARATORS OFF - BIT 3
CM2CON0 = %01000000
VRCON.7 = 0 ; VOLTAGE REFERENCE OFF
; OPAMP CONTROL REGISTER
OPACON = %00000011 ; OPAMPS ON
BLINK:
HIGH LED
PAUSE 500
LOW LED
PAUSE 500
GOTO BLINK
end