Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

PIC16LF877 device problem - help please

Status
Not open for further replies.

tomovill

Junior Member level 3
Joined
Oct 21, 2001
Messages
27
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Hungary
Activity points
98
PIC problem

I programming a PIC16LF877 device. I have wrote an easy subrutin:

PROG
BSF XSET
BSF YSET
BSF ZSET
BSF AUTOLED
L6
BSF ACK ;PROGRAM INDULHAT
CALL WAITMS
BCF ACK
MOVF PORTB,0
MOVWF PORTC ;MÁSOLÁS PORTC -RE, AHOL A MOTOROK VANNAK
CALL WAITMS
BTFSS ALAPH ;HA NEM ALPHELYZETRE
GOTO L6 ;EL?R?L
CALL ALAPHE ;ALAPHELYZETRE ÁLLÍTÁS
RETURN

END ;PROGRAM VÉGE

This subrutin must be copying portb to portc.
Portb comes on a PC LPT. Portc goes to stepper motors driver (MC3479).

Problem:

When PB3 is on high => no problem, everything is good.
When RB3 is on low => everything is good, bot only on RB4 is 1,2V and not copying on RC4

What is the problem?
 

nooknikz

Full Member level 5
Joined
Apr 22, 2002
Messages
318
Helped
25
Reputation
50
Reaction score
3
Trophy points
1,298
Location
thailand
Activity points
2,303
you config Low voltage programming OR High voltage programming ?
 

tomovill

Junior Member level 3
Joined
Oct 21, 2001
Messages
27
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Hungary
Activity points
98
I have configured LVP_OFF.
But when LVP is on then i mean RB7, RB6 will not work to. This pins are good. Only with the RB3 and RB4 is problem.
But the RC port is with I2C multiplexed (RC3 and RC4). The I2C mode but i have turned off.
I dont know what is the problem.

Sorry to my english

Tomo
 

S

sick_man

Guest
Re: PIC problem

BSF XSET
BSF YSET
BSF ZSET
BSF AUTOLED
L6
BSF ACK ;PROGRAM INDULHAT
CALL WAITMS
BCF ACK
MOVF PORTB,0
MOVWF PORTC
CALL WAITMS
BTFSS ALAPH ;HA NEM ALPHELYZETRE
GOTO L6 ;EL?R?L
CALL ALAPHE ;ALAPHELYZETRE ÁLLÍTÁS
RETURN

END ;PROGRAM VÉGE

you cant do this

if you want too move the whole port over

PROG
BSF XSET
BSF YSET
BSF ZSET
BSF AUTOLED
L6
BSF ACK ;PROGRAM INDULHAT
CALL WAITMS
BCF ACK
MOVF PORTB,
MOVWF PORTC <<<<<<<<<PORT C WHAT??????
CALL WAITMS
BTFSS ALAPH ;HA NEM ALPHELYZETRE
GOTO L6 ;EL?R?L
CALL ALAPHE ;ALAPHELYZETRE ÁLLÍTÁS
RETURN

END ;PROGRAM VÉGE

BCF ACK
MOVF PORTB,
MOVWF PORTC <<<<<<<<<PORT C WHAT??????



YOU NEED TOO SET UP THE INIT TOO ENABLE THE PORT B PULLUPS AND DISABLE SPECIAL FUNCTIONS OF PORT B PINS

LOOK IN MICROCHIP GENERAL MICROCONTROLLER REFERANCE FOR THE CORRECT SETTINGS

IF YOU GET A PROBLEM WITH PORT B4 B5 THEN TRY SETTING THE PORT AS A PORT NOT JUST ONE BIT



HERE IS A TYPICAL INIT BLOCK FOR A PIC84


Start
bsf STATUS, RP0 ; select bank 1
movlw OPTIONVAL
movwf OPTION_REG ; set options in PIC
movlw TRISAVAL
movwf TRISA ; set port A direction bits
movlw TRISBVAL ; set PORTB for all output
movwf TRISB
bcf STATUS, RP0 ; select bank 0

clrf Move_Number
clrf Tone
clrf flags




DONT FORGET TOO CLRW BEFORE THE NEXT MAIN PASS LOOP IN YOUR ROUTINE

OR YOULL GET AN OVERFLOW
 

se7en

Member level 2
Joined
Dec 10, 2002
Messages
44
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
195
it may be a defective port
 

tomovill

Junior Member level 3
Joined
Oct 21, 2001
Messages
27
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Hungary
Activity points
98
Dear !!!MONKEY!!!

Here is my port initialization:


INI_PORT

BANKSEL TRISA ;BANK1 VÁLTÁS
MOVLW B'00000110' ;DIGITÁLIS
MOVWF ADCON1
MOVLW B'00011110' ;PORTA IRÁNYÁNAK BEÁLLÍTÁSA
MOVWF TRISA
MOVLW B'11111111' ;PORTB MIND BEMENET
MOVWF TRISB
MOVLW B'10000000' ;PORTC IRÁNYÁNAK BEÁLLÍTÁSA
MOVWF TRISC
MOVLW B'00111111' ;PORTD IRÁNYÁNAK BEÁLLÍTÁSA
MOVWF TRISD
CLRF TRISE
BANKSEL PORTA ;BANK0 VÁLTÁS
CLRF PORTA ;PORTA TÖRLÉSE
CLRF PORTB ;PORTB TÖRLÉSE
CLRF PORTC ;PORTC TÖRLÉSE
CLRF PORTD ;PORTD TÖRLÉSE
CLRF PORTE ;PORTE MOTOROK ÁRAMÁNAK

I mean this is good.

The MOVF PORTB,0 is not moving one bit of portc
From the Datasheet of the PIC16F87X instructions descriptions:

MOVF f,d
d ={0,1}
The contents of register f are moved to a destination dependant upon the status of d. If d=0, destination is W register. If d=1, the destination is file register f itself. d=1 is useful to test a fileregister, since status flag Z is affected.
 

reiniheini

Member level 1
Joined
Jun 21, 2001
Messages
38
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
269
Hi!

Have you disabled In Circuit Debugging?
I think this uses this pin!

Bye reini
 

reiniheini

Member level 1
Joined
Jun 21, 2001
Messages
38
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
269
Hi tomovill!

Sorry my mistake! The Pin RB4 is not mapped with any third function.
Make sure you have connected both GND-pins!

Otherwise I agree with se7en. The pin should be damaged.

Bye reini
 

rrodriguez

Junior Member level 3
Joined
Apr 12, 2002
Messages
28
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
148
The problem that you have is that RB4 pin on PIC**877 does not have internal connection to GND and this is a problem when you use RB4 as out. You need forced this out to GND putting a 10K resistor to GND.

Regards.
 

C-Man

Advanced Member level 4
Joined
Jul 19, 2001
Messages
1,059
Helped
90
Reputation
180
Reaction score
17
Trophy points
1,318
Activity points
10,191
RRODRIGUEZ you are mixing things up:
on the 16F877 (and other PIC devices) PORTA has the problem that RA4 can not give out a '1' when used as output because it is an open drain output. So you need a pullup on RA4 to output a '1'.

To tomovill:

If you are having the problem only on RB3 and RB4 I would assume you have the problem on RC3 and RC4 which can also be used as I2C bus ...

You should check the initialisation code for the MSSP port to see if you enabled I2C mode.

best regards
 

jhonny_yang

Full Member level 2
Joined
Mar 8, 2002
Messages
130
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,298
Activity points
992
Floating ???

Maybe that is floating problem i agree to connect RA4 with 4.7 K to ground. And the other possible is your setting i/o wrong it's hard to say that's a program bug.

try to attach your schematic in this forum. so we clearly is it hardware problem or software problem. thank's
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top