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
 
Thread Tools Display Modes
Old 5th February 2008, 02:07 PM   (permalink)
Default Need Help! PIC16F877A Port Initialization

I just want to ask how to correctly initialize a PORT in PIC16F877a cause its my first time using usually i used PIC16F84A due to more inputs a shift to pic16f877a but my problem is that i cannot correctly initialize PORTA of PIC16F877a due to the ADC function sharing with the port. Because i want to used my PORTA as an input for my sensors which i cannot distinguish either analog or digital.

Is the common sensor which is compose of IR and Phototransistor output an analog or digital signal?
Klitzie is offline   Reply With Quote
Old 5th February 2008, 02:21 PM   (permalink)
Default

Quote:
Originally Posted by Klitzie
I just want to ask how to correctly initialize a PORT in PIC16F877a cause its my first time using usually i used PIC16F84A due to more inputs a shift to pic16f877a but my problem is that i cannot correctly initialize PORTA of PIC16F877a due to the ADC function sharing with the port. Because i want to used my PORTA as an input for my sensors which i cannot distinguish either analog or digital.
The datasheet expalins it, or you could check my tutorials.

Quote:

Is the common sensor which is compose of IR and Phototransistor output an analog or digital signal?
Usually digital.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline   Reply With Quote
Old 5th February 2008, 02:23 PM   (permalink)
Default

If you look in the data sheet it has this code snippet to setup port A.
Code:
	BCF	STATUS,RP0
	BCF	STATUS,RP1	; Bank0
	CLRF	PORTA		; Initialize PORTA by
				; clearing output
				; data latches
	BSF	STATUS, RP0	; Select Bank 1
	MOVLW	0x06		; Configure all pins
	MOVWF	ADCON1		; as digital inputs
	MOVLW	0xCF		; Value used to
				; initialize data
				; direction
	MOVWF	TRISA		; Set RA<3:0> as inputs
				; RA<5:4> as outputs
				; TRISA<7:6>are always
				; read as '0'.
HTH

Mike.
Pommie is offline   Reply With Quote
Old 5th February 2008, 04:42 PM   (permalink)
Default

Im using a pic-lite compiler it doing my program, im not good in assembly, can you convert this to a c code.
Klitzie is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
Need help badly on Inchworm and MPLAB thushy Micro Controllers 14 11th March 2007 06:05 PM
8051 port initialization 4electros Micro Controllers 5 30th January 2007 12:34 PM
PIC16F877A interfacing with Serial Port jasbertfalutine Micro Controllers 10 18th June 2006 07:25 AM
Chip talk dreamproject Electronic Projects Design/Ideas/Reviews 8 2nd April 2005 07:24 PM
Motor control interface dreamproject Micro Controllers 0 31st March 2005 03:48 AM



All times are GMT. The time now is 12:06 AM.


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