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.

pic16f628 and pic16f628A PORTA difference

Status
Not open for further replies.

selfish

Newbie level 5
Joined
Feb 23, 2008
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,345
I can not make some of my PIC16f628A port outputs. RA0,RA1?

I was using PIC16f628 and it was working propely.

With the same code i have this problem with PIC16f628A.

I have disabled the comparator on PORTB, but the problem is still there.

Can anyone help please?
 

Hi WP100,

I am sorry for the delay. I ried to extract the early part of the code (set up and main) but that created other problems. (full of errors)

I do not have knowledge to resolve them. However i can give more details of the problem. I was using PicKit-2 (clone from futurelec). As MPLAB does not suppot PIC16f628 i was using the dedicated software supplied with the programmer. When i changed to PIC16f628A i am sunig MPLAB for programing. Also i do not have the dedcated software supplied with the programmer anymore. So it is possible that my programmer is not fully compatible with MPLAB?
 

Hi.

You are really talking about 2 different problems.

First your Code problem - unless we can see you code its difficult for anyone to locate the error - just cut and paste the relevant bits of code and enclose it within the Code Tags.

Cannot see any documentation for the Futurelec Pk2 programmer, but would assume it is a 'true' clone and is using all the software from Microchip.
As you say, the 628 will not program direclty from MPlab but the 628A will. The Pickit2 Stand Alone program V2.61 is probably what you used to directly program the 628. All that software is freely available on the Microchip Pickit2 website.

Cannot see the programer issues having anything to do with your Port problem.
 

Hi WP 100,

Thank you for the response. I think you are correct. Only i can not confirm as i can not programme 628 now. However i reduce my code and now i have a running programme (switching PORTA and PORTB on and off with low frequency)The zip file is attached. Can you please have a look?
 

Hi WP-100,

This is a simple code that does work with 628 and does not work with 628A. (Some of the pins are not flahing with 628A) Please ignor RB3 because of PWM configuration.

list p=16f628A

#include "p16f628A.inc"
UDATA 0x40
TIMER res 1
__config 0X0078

CODE
STARTUP CODE 0X0

SETUP

banksel CMCON
movlw 0X7
movwf CMCON


banksel OPTION_REG
clrf OPTION_REG

movwf OPTION_REG

banksel PIE1
clrf PIE1
bsf PIE1,TMR1IE

banksel T1CON
clrf T1CON

bsf T1CON,TMR1ON
bsf T1CON,T1CKPS0
bsf T1CON,T1CKPS1

banksel T2CON
clrf T2CON
bsf T2CON,TMR2ON
bsf T2CON,T2CKPS1
banksel CCP1CON
movlw 0XC
movwf CCP1CON
banksel CCPR1L
movlw 0X30
movwf CCPR1L

banksel PR2
movlw 0XF0; Freq=F(Osc)/(PR2+1)/(PS=16)/4
movwf PR2

clrf INTCON
bsf INTCON,7 ;Enable global interrupt
bsf INTCON,6


banksel TRISA
clrf TRISA
clrf TRISB

banksel PORTA
MAIN
btfss TMR1H,7
goto MAIN
clrf TMR1H
incf TIMER

btfsc TIMER,1
goto RESET1


btfss TIMER,1
goto SET1
goto MAIN

SET1
movlw 0XFF
movwf PORTA
movwf PORTB
goto MAIN
RESET1
clrf PORTA
clrf PORTB
goto MAIN

end
 

First guess - what is OPTION_REG supposed to hold? You clear it then immediately load 0x07 into it.
Second guess - where is the interrupt handler? You enable interrupts but jump into a banksel instruction instead of servicing it.

Please also use bit names to make the program easier to read. for example, instead of using "bsf INTCON,7" use "bsf INTCON,GIE".
Similarly, the configuration 0x0078 doesn't mean a lot without the data sheet to decode it, please use the names of the config parameters.

Brian.


Brian.
 

Hi,

Think you ought to go back to basics to see where your port problem is.

Use the 16F628A Template file ( in MPasm directory) as your guide and try turning on the Ports with just simple code.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top