Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

pic16f526 PORTB GPIO init problem

Status
Not open for further replies.

goran_86

Newbie level 1
Joined
Nov 24, 2009
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
zagreb
Activity points
1,297
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
 

Hi,

Disable portB pullups, then try.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top