ALEXAN
- 10th September 2014, 04:58
Hi ,
I want to use 18F23K22 device in my proyect , after a lot of time reading the datasheet and Melabs configurator can't get blink a simple led with this device, maybe someone can give me help to find the mistake in my code.
Here the code:
#CONFIG
CONFIG FOSC = HSMP ; HS oscillator (medium power 4-16 MHz)
CONFIG PLLCFG = OFF ; Oscillator used directly
CONFIG PRICLKEN = ON ; Primary clock enabled
CONFIG FCMEN = OFF ; Fail-Safe Clock Monitor disabled
CONFIG IESO = OFF ; Oscillator Switchover mode disabled
CONFIG PWRTEN = OFF ; Power up timer disabled
CONFIG BOREN = SBORDIS ; Brown-out Reset enabled in hardware only (SBOREN is disabled)
CONFIG BORV = 190 ; VBOR set to 1.90 V nominal
CONFIG WDTEN = OFF ; Watch dog timer is always disabled. SWDTEN has no effect.
CONFIG WDTPS = 32768 ; 1:32768
CONFIG CCP2MX = PORTC1 ; CCP2 input/output is multiplexed with RC1
CONFIG PBADEN = OFF ; PORTB<5:0> pins are configured as digital I/O on Reset
CONFIG CCP3MX = PORTB5 ; P3A/CCP3 input/output is multiplexed with RB5
CONFIG HFOFST = ON ; HFINTOSC output and ready status are not delayed by the oscillator stable status
CONFIG T3CMX = PORTC0 ; T3CKI is on RC0
CONFIG P2BMX = PORTB5 ; P2B is on RB5
CONFIG MCLRE = EXTMCLR ; MCLR pin enabled, RE3 input pin disabled
CONFIG STVREN = ON ; Stack full/underflow will cause Reset
CONFIG LVP = OFF ; Single-Supply ICSP disabled
CONFIG XINST = OFF ; Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
CONFIG DEBUG = OFF ; Disabled
CONFIG CP0 = OFF ; Block 0 (000200-000FFFh) not code-protected
CONFIG CP1 = OFF ; Block 1 (001000-001FFFh) not code-protected
CONFIG CPB = OFF ; Boot block (000000-0001FFh) not code-protected
CONFIG CPD = OFF ; Data EEPROM not code-protected
CONFIG WRT0 = OFF ; Block 0 (000200-000FFFh) not write-protected
CONFIG WRT1 = OFF ; Block 1 (001000-001FFFh) not write-protected
CONFIG WRTC = OFF ; Configuration registers (300000-3000FFh) not write-protected
CONFIG WRTB = OFF ; Boot Block (000000-0001FFh) not write-protected
CONFIG WRTD = OFF ; Data EEPROM not write-protected
CONFIG EBTR0 = OFF ; Block 0 (000200-000FFFh) not protected from table reads executed in other blocks
CONFIG EBTR1 = OFF ; Block 1 (001000-001FFFh) not protected from table reads executed in other blocks
CONFIG EBTRB = OFF
#ENDCONFIG
DEFINE OSC 4
OSCCON.0=0 'System Clock Primary Select Clock bit 0
OSCCON.1=0 'System Clock Primary Select Clock bit 1
CM1CON0.7=0 'Comparator 1 Off
CM2CON0.7=0 'Comparator 2 Off
ADCON0.0=0 'ADON:ADC Enable bit disabled
ANSELA=%00000000 'PortA Digital
ANSELB=%00000000 'PortB Digital
ANSELC=%00000000 'Portc Digital
INTCON=%00000000 'Disable All Interrupts
INTCON2.7=1 'PortB Pull Up Disabled
WPUB=%11000000 'Single PortB Pull Up PORTB0~PORTB7 enabled
TRISA=%00000000 'PortA All Output
TRISB=%00000000 'Portb All Output
TRISC=%00000000 'PortC All Output
LED1 VAR PORTC.0
MainLoop:
HIGH LED1
PAUSE 500
LOW LED1
Goto Mainloop
end
I want to use 18F23K22 device in my proyect , after a lot of time reading the datasheet and Melabs configurator can't get blink a simple led with this device, maybe someone can give me help to find the mistake in my code.
Here the code:
#CONFIG
CONFIG FOSC = HSMP ; HS oscillator (medium power 4-16 MHz)
CONFIG PLLCFG = OFF ; Oscillator used directly
CONFIG PRICLKEN = ON ; Primary clock enabled
CONFIG FCMEN = OFF ; Fail-Safe Clock Monitor disabled
CONFIG IESO = OFF ; Oscillator Switchover mode disabled
CONFIG PWRTEN = OFF ; Power up timer disabled
CONFIG BOREN = SBORDIS ; Brown-out Reset enabled in hardware only (SBOREN is disabled)
CONFIG BORV = 190 ; VBOR set to 1.90 V nominal
CONFIG WDTEN = OFF ; Watch dog timer is always disabled. SWDTEN has no effect.
CONFIG WDTPS = 32768 ; 1:32768
CONFIG CCP2MX = PORTC1 ; CCP2 input/output is multiplexed with RC1
CONFIG PBADEN = OFF ; PORTB<5:0> pins are configured as digital I/O on Reset
CONFIG CCP3MX = PORTB5 ; P3A/CCP3 input/output is multiplexed with RB5
CONFIG HFOFST = ON ; HFINTOSC output and ready status are not delayed by the oscillator stable status
CONFIG T3CMX = PORTC0 ; T3CKI is on RC0
CONFIG P2BMX = PORTB5 ; P2B is on RB5
CONFIG MCLRE = EXTMCLR ; MCLR pin enabled, RE3 input pin disabled
CONFIG STVREN = ON ; Stack full/underflow will cause Reset
CONFIG LVP = OFF ; Single-Supply ICSP disabled
CONFIG XINST = OFF ; Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
CONFIG DEBUG = OFF ; Disabled
CONFIG CP0 = OFF ; Block 0 (000200-000FFFh) not code-protected
CONFIG CP1 = OFF ; Block 1 (001000-001FFFh) not code-protected
CONFIG CPB = OFF ; Boot block (000000-0001FFh) not code-protected
CONFIG CPD = OFF ; Data EEPROM not code-protected
CONFIG WRT0 = OFF ; Block 0 (000200-000FFFh) not write-protected
CONFIG WRT1 = OFF ; Block 1 (001000-001FFFh) not write-protected
CONFIG WRTC = OFF ; Configuration registers (300000-3000FFh) not write-protected
CONFIG WRTB = OFF ; Boot Block (000000-0001FFh) not write-protected
CONFIG WRTD = OFF ; Data EEPROM not write-protected
CONFIG EBTR0 = OFF ; Block 0 (000200-000FFFh) not protected from table reads executed in other blocks
CONFIG EBTR1 = OFF ; Block 1 (001000-001FFFh) not protected from table reads executed in other blocks
CONFIG EBTRB = OFF
#ENDCONFIG
DEFINE OSC 4
OSCCON.0=0 'System Clock Primary Select Clock bit 0
OSCCON.1=0 'System Clock Primary Select Clock bit 1
CM1CON0.7=0 'Comparator 1 Off
CM2CON0.7=0 'Comparator 2 Off
ADCON0.0=0 'ADON:ADC Enable bit disabled
ANSELA=%00000000 'PortA Digital
ANSELB=%00000000 'PortB Digital
ANSELC=%00000000 'Portc Digital
INTCON=%00000000 'Disable All Interrupts
INTCON2.7=1 'PortB Pull Up Disabled
WPUB=%11000000 'Single PortB Pull Up PORTB0~PORTB7 enabled
TRISA=%00000000 'PortA All Output
TRISB=%00000000 'Portb All Output
TRISC=%00000000 'PortC All Output
LED1 VAR PORTC.0
MainLoop:
HIGH LED1
PAUSE 500
LOW LED1
Goto Mainloop
end