Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 1st November 2003, 09:59 AM   (permalink)
Default wierd problem with 16f628

I'm trying to use 16f628's porta as an output but for some reason it doesn't work. at least when i'm simulating with mplab's simulator. the problem is that i cannot change the state of porta's 0-3 pins. They are always 0. so only RA4 is working.

my code is:

LIST P=16F628
radix hex
#include "P16F628.INC" ; Include header file

__config _INTRC_OSC_NOCLKOUT & _LVP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_ON



ORG 0x000 ; Program starts at 0x000

BSF STATUS,RP0 ; bank 1
CLRF TRISA ;all output
BCF STATUS,RP0 ; back to bank 0

CLRF PORTA

LOOP:
BSF PORTA,4 ;RA4 goes up
BCF PORTA,4 ;RA4 goes down
BSF PORTA,3 ;nothing happens
BSF PORTA,2 ;nothing happens
BSF PORTA,1 ;nothing happens
BSF PORTA,0 ;nothing happens
GOTO LOOP
END

can you see any clear errors or have you had same kind of problem??
Or is the error in simulator??

a
eeanma is offline  
Old 1st November 2003, 12:29 PM   (permalink)
Default

PIC 16F628 has comparators on portA. They are ON by default, so if you want ,to use portA pins as normal I/O you must first turn the comparator off

Add the following lines to the top of your code

MOVLW 0x07
MOVWF CMCON
Exo is offline  
Old 1st November 2003, 12:43 PM   (permalink)
Default thanks!!

It works.thanks.great site..

a
eeanma is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 03:55 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker