goran_86
Newbie level 1
I work on a project with PIC16F526.
I have a problem with PORTB initialization.
A part of code is presented below
;---------------------------------------------------------------------------------------
;CPU initialization
;---------------------------------------------------------------------------------------
CPU_init macro
;---------------------------------------------------------------------------------------
;clear RAM location (10h-1Fh) using indirect adressing
movlw 0x10 ;initialize pointer
movwf FSR ;to RAM
Next
clrf INDF ;clear INDF register
incf FSR, f ;increment pointer
btfsc FSR, 4 ;all done?
goto Next ;clear 1Fh-10h=Fh=15
;---------------------------------------------------------------------------------------
bcf STATUS, PA0 ;select Page0(000h-1FFh)
bcf ADCON0, ADON ;ADC module is shut-off
bcf CM1CON0, C1ON ;Comparator1 is off
bcf CM2CON0, C2ON ;Comparator2 is off
movlw 0x3F
tris PORTB
movlw 0x11
tris PORTC
endm
This is my config line:
__CONFIG _CPDF_OFF&_MCLRE_OFF&_CP_OFF&_WDTE_OFF&_IOSCFS_4MHz&_IntRC_OSC_RB4
This is my main
org 0x35
main
PowerOn
CPU_init
...........
...........
...........
When I init PORTB, 4 and PORTB, 5 as input or output (with config _IntRC_OSC_RB4) it does not work as input or output, but when I do this (_IntRC_OSC_CLKOUT) it works as clock output signal on pin RB4.
The same problem is with all PORTB pins. PORTC pins work fine.
Thank you for your help.
Goran
I have a problem with PORTB initialization.
A part of code is presented below
;---------------------------------------------------------------------------------------
;CPU initialization
;---------------------------------------------------------------------------------------
CPU_init macro
;---------------------------------------------------------------------------------------
;clear RAM location (10h-1Fh) using indirect adressing
movlw 0x10 ;initialize pointer
movwf FSR ;to RAM
Next
clrf INDF ;clear INDF register
incf FSR, f ;increment pointer
btfsc FSR, 4 ;all done?
goto Next ;clear 1Fh-10h=Fh=15
;---------------------------------------------------------------------------------------
bcf STATUS, PA0 ;select Page0(000h-1FFh)
bcf ADCON0, ADON ;ADC module is shut-off
bcf CM1CON0, C1ON ;Comparator1 is off
bcf CM2CON0, C2ON ;Comparator2 is off
movlw 0x3F
tris PORTB
movlw 0x11
tris PORTC
endm
This is my config line:
__CONFIG _CPDF_OFF&_MCLRE_OFF&_CP_OFF&_WDTE_OFF&_IOSCFS_4MHz&_IntRC_OSC_RB4
This is my main
org 0x35
main
PowerOn
CPU_init
...........
...........
...........
When I init PORTB, 4 and PORTB, 5 as input or output (with config _IntRC_OSC_RB4) it does not work as input or output, but when I do this (_IntRC_OSC_CLKOUT) it works as clock output signal on pin RB4.
The same problem is with all PORTB pins. PORTC pins work fine.
Thank you for your help.
Goran