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.

digital input for pic16f877 on PORT A

Status
Not open for further replies.

yllongboy

Newbie level 6
Joined
Dec 9, 2006
Messages
11
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,362
pic16f877 porta

hi there..
could anyone help me with my problem ....
im trying to send data on port A of pic16f877
but nothing happens... here is my sample code....



list p=16f877
#include <p16f877.inc>


__CONFIG _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_ON & _XT_OSC & _WRT_ENABLE_ON & _LVP_ON & _DEBUG_OFF & _CPD_OFF






ORG 0x00



start


CLRW


BSF STATUS, RP0


MOVLW 0x06
MOVWF ADCON1
MOVLW 0X00
movwf trisa
BCF STATUS, RP0


LOOP

MOVLW 0XFF
MOVWF PORTA
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
movlw 0x00
movwf porta
GOTO LOOP
END

..... this is just a simple blinking of the led... just to see if i could really send data to port A
 

pic16f877 adcon1 digital io

yllongboy said:
hi there..
could anyone help me with my problem ....
im trying to send data on port A of pic16f877
but nothing happens... here is my sample code....

list p=16f877
#include <p16f877.inc>

__CONFIG _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_ON & _XT_OSC & _WRT_ENABLE_ON & _LVP_ON & _DEBUG_OFF & _CPD_OFF

ORG 0x00

start


CLRW


BSF STATUS, RP0


MOVLW 0x06
MOVWF ADCON1
MOVLW 0X00
movwf trisa
BCF STATUS, RP0


LOOP

MOVLW 0XFF
MOVWF PORTA
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
movlw 0x00
movwf porta
GOTO LOOP
END

bsf STATUS,RP0 ;set to Bank 1
MOVLF B'00000111',ADCON1 ;setting all AD pins to digital I/O
clrf TRISA ;setting all port a to output


also look at the word start
see others structs to follow namings although it may work its not good practice


also

HS osc is to enable HIGH SPEED crystal >4mhz so if your using
a crystal it will sit and do nothing
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_ON & _HS_OSC & _WRT_ENABLE_ON & _LVP_ON & _DEBUG_OFF & _CPD_OFF

dont forget to add +5v via a 10k res to the mclr pin or the chip wont boot



**broken link removed**
 

pic16f877a porta

thank you for the posted rply.....
.... i already followed all the instructions above and it seems that it is still not working.... i could not get any output from port A so as all other ports...
... could somebody help me solve my problem. It would be better if there would be a sample running circuit..
...
thank you...
 

port 16f877 a-e

Hi,
I think you should try by keeping lvp off if you are note using it .

according to your code off time for yor led is only two or three instruction cycles at 4mhz it amounts to 3 micro seconds. I gus you need atleast 250milliseconds on off time to see a flashing led.
Thanks
 

adcon1 16f877

yllongboy said:
thank you for the posted rply.....
.... i already followed all the instructions above and it seems that it is still not working.... i could not get any output from port A so as all other ports...
... could somebody help me solve my problem. It would be better if there would be a sample running circuit..
...
thank you...

http://www.piclist.com/techref/microchip/16F877/flashled.htm
 

using porta of pic16f877

hi,
If you are using 16F877A all the ports will be in input mode.
you have to change it in out put mode , otherwise your pic may damage.
there are four problems I found in your code.

1, when you are using LVP_ON you have to pull down LVP pin
2, tris command should be in capital letter TRISA
3, port command also should in capital PORTA
4, use some noticable delay between changing ports so that you can identify.

Note: TRY PORTB OR PORTC FIRST THEN MOVE TO PORTA

TRY THIS CODE
Code:
list p=16f877 
#include <p16f877.inc> 

__CONFIG _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_ON & _XT_OSC & _WRT_ENABLE_ON & _LVP_OFF & _DEBUG_OFF & _CPD_OFF 

VARIABLE_DECLARATIONS

	CBLOCK 0X20
DELAY_L
DELAY_M
DELAY_H
	ENDC

ORG 0x00 

INITIALISE_PORTS
	BANKSEL PORTA
	clrf PORTA
	clrf PORTB
	clrf PORTC
	clrf PORTD
	clrf PORTE
	BANKSEL TRISA
	clrf TRISA
	clrf TRISB
	clrf TRISC
	clrf TRISD
	clrf TRISE
	BANKSEL ADCON1
	movlw b'00000110'
	movwf ADCON1
	BANKSEL PORTA

START

LOOP 

	MOVLW 0XFF 
	MOVWF PORTA 
	call DELAY350MS
	movlw 0x00 
	movwf PORTA 
	call DELAY350MS
	GOTO LOOP 
;##################
DELAY350MS
	movlw 0XFF
	movwf DELAY_L
	movwf DELAY_M
	movlw 0X09
	movwf DELAY_H
AGAIN
	decfsz DELAY_L
	goto AGAIN
	decfsz DELAY_M
	goto AGAIN
	decfsz DELAY_H
	goto AGAIN
	return
		END

good luck
 

how can set adcon1 to digital input in pic16f877a

thanks for the rply.. can i have a circuit on this one.. i already tried it but it seems that my circuit doesnt work... i think my problem now is on the hardware side..
could anyone post a circuit..
thanks..
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top