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.

uart problem with pgm pin of 16f877a

Status
Not open for further replies.

asthra123

Member level 1
Member level 1
Joined
Jul 2, 2013
Messages
32
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,582
sir,
i am using pickit2 for programming and pickit2 uart tool for checking data from pic16f877 but the uart window showing 0D 0D......
but when I am touching the pgm pin the data is receiving correctly from pic. I done the programming both LVPON mode with 10k pull down resistor and LVPOFF mode with out the resistor also. please note I am not well experienced with microcontrollers ,attaching my asm code with this. please help me
seby
 

Hi,

Normally you should always have LVP= OFF in your Config code, its simply is not needed when using the Pk2.

The Usart tool does work ok, have you got your code set up correctly and the Baud rates of your code and the Usart Tool the same.

You have not posted any code....
 

dear sir ,
this is my asm code for 16 channel multiplexed input from cd4066 ,please note that i am new to microcontollers
please help me


list p=16f877 ; list directive to define processor
#include <p16f877.inc> ; processor specific variable definitions

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






Adcnt equ 20h ;a/d ad converter pin count register
Adcntw equ 21h ;ad converter pin count register
Temp equ 22h ;temperary data holding register seems we always need one
org 0h
goto init ;go to where our core really begins
org 5h ;bigin program above interrupt service vector address
init bcf INTCON,7 ;make sure we dont interrupted
clrf PORTA ;don't rely on any thing, set port lachs where you want them
clrf PORTB
clrf PORTC
clrf PORTD
clrf PORTE
clrf Adcnt ;clear ram registers we will be using
clrf Adcntw
clrf Temp
bsf STATUS,RP0 ;switch to page 1 to access trisX registers
clrf TRISB ;set all ports output
clrf TRISC ;just for this program to mininize current
clrf TRISD ;and prevent from floting
clrf TRISE
movlw 0fh
movwf TRISA ;set analog inputs as inputs,the rest as outputs
bcf STATUS,RP0 ;

initad movlw 0C1h ;internal RC A/D clock input channel 0 ,A/D on
movwf ADCON0 ;(wait for spcified period before sampling
bsf STATUS,RP0 ;select page 1 of SFRs
movlw b'00000000'
movwf ADCON1 ;setup A/D inputs on RA0 ,RA1,and RA3 with Vref=Vdd
;we are still in page 1 of SFRs
initsci movlw 19h ;set baud rate 2400
movwf SPBRG
movlw 25h ;set up for async operation
movwf TXSTA
bcf STATUS,RP0 ;back to file 0 for a moment
movlw 80h ;enable serial port operations and the associated pins
movwf RCSTA
clrf TXREG ;clear our serial port buffers for start up
clrf RCREG
initpwm movlw 4h ;set up T2CON0 with prescaler = 0 and timer2 on
movwf T2CON
movlw 0fh ;set up capture/copare to PWM mode standard resolution
movwf CCP2CON
movlw 0fh ;set compare registor to half for now
movwf CCPR2L
bsf STATUS,RP0 ;select page 1 for pr2 registor
movlw 0ffh
movwf PR2
bcf STATUS,5
iniportr
bsf STATUS,5
movlw b'11111001'
movwf TRISB
bcf STATUS,5
movlw b'11111101'
movwf PORTB
movlw 0Ah
call sendat
movlw 58h
call sendat
call iniporte
clrf PORTB
bsf STATUS,5
movlw b'11111001'
movwf TRISB
bcf STATUS,5
movlw b'11111011'
movwf PORTB
movlw 0Ah
call sendat
movlw 59h
call sendat
call iniporte
clrf PORTB
bsf STATUS,5
movlw b'11111001'
movwf TRISB
bcf STATUS,5
movlw b'11111111'
movwf PORTB
movlw 0Ah
call sendat
movlw 5ah
call sendat
call iniporte
clrf PORTB

goto iniportr
iniporte bsf STATUS,5
movlw b'00010000'
movwf TRISD
bcf STATUS,5
movlw b'11110000' ;0
movwf PORTD
call mloop
clrf PORTD
bsf STATUS,5
movlw b'00010000'
movwf TRISD
bcf STATUS,5
movlw b'11110001' ;1
movwf PORTD
call mloop
clrf PORTD
bsf STATUS,5
movlw b'00010000'
movwf TRISD
bcf STATUS,5
movlw b'11110010' ;2
movwf PORTD
call mloop
clrf PORTD
bsf STATUS,5
movlw b'00010000'
movwf TRISD
bcf STATUS,5
movlw b'11110011' ;3
movwf PORTD
call mloop
clrf PORTD
bsf STATUS,5
movlw b'00010000'
movwf TRISD
bcf STATUS,5
movlw b'11110101' ;4
movwf PORTD
call mloop
clrf PORTD
bsf STATUS,5
movlw b'00010000'
movwf TRISD
bcf STATUS,5
movlw b'11110110' ;5
movwf PORTD
call mloop
clrf PORTD
bsf STATUS,5
movlw b'00010000'
movwf TRISD
bcf STATUS,5
movlw b'11110111' ;6
movwf PORTD
call mloop
clrf PORTD
bsf STATUS,5
movlw b'00010000'
movwf TRISD
bcf STATUS,5
movlw b'11111000' ;7
movwf PORTD
call mloop
clrf PORTD
bsf STATUS,5
movlw b'00010000'
movwf TRISD
bcf STATUS,5
movlw b'111111001' ;8
movwf PORTD
call mloop
clrf PORTD
bsf STATUS,5
movlw b'00010000'
movwf TRISD
bcf STATUS,5
movlw b'11111010'
movwf PORTD
call mloop
clrf PORTD
bsf STATUS,5
movlw b'00010000'
movwf TRISD
bcf STATUS,5
movlw b'11111011'
movwf PORTD
call mloop
clrf PORTD
bsf STATUS,5
movlw b'00010000'
movwf TRISD
bcf STATUS,5
movlw b'11111100'
movwf PORTD
call mloop
clrf PORTD
bsf STATUS,5
movlw b'00010000'
movwf TRISD
bcf STATUS,5
movlw b'11111001'
movwf PORTD
call mloop
clrf PORTD
bsf STATUS,5
movlw b'00010000'
movwf TRISD
bcf STATUS,5
movlw b'11111110'
movwf PORTD
call mloop
clrf PORTD
bsf STATUS,5
movlw b'00010000'
movwf TRISD
bcf STATUS,5
movlw b'11111111'
movwf PORTD
call mloop
clrf PORTD
return
mloop ;send a carrige return charecter
;bigin main loop for data gathering and ;serial transmission
;these are our sync bit to tell receiving ;micro a nen
;sequence is begining
movlw 09h

call sendat

clrf Adcnt ;our first time through select AN0 pin
adloop call adcnvrt ;go do a conversion and send the result
call adcnvrt1
call adcnvrt2
call adcnvrt3
return ;all done go do it again
adcnvrt
movlw 0C1h ;load the initial ADCON0 valu excepting;channel select

movwf ADCON0 ;set the new ADCON0 with new channels selected
call wait ;wait about twenty mico seconds
bsf ADCON0,2 ;start conversion
incf Adcnt ;increment pin counter register
adwait btfsc ADCON0,2 ;wait for conversion done
goto adwait ;not done yet
swapf ADRESH,W ;conversion done, swap result nibbles in to W register
andlw 0Fh ;mask off the upper nibble to limit number to an ascii range
addlw 30h ;convert to ascii character to make it visible to terminal

sendat bsf STATUS,RP0 ;select page one
btfss TXSTA,1 ;check transmit status ready to send
goto sendat ;if not ready go to try again
bcf STATUS,RP0 ;back to page 0
movwf TXREG ;transmit buffer empty send new data

return
adcnvrt1
movlw 0c9h ;load the initial ADCON0 valu excepting channel select

movwf ADCON0 ;set the new ADCON0 with new channels selected
call wait ;wait about twenty mico seconds
bsf ADCON0,2 ;start conversion
incf Adcnt ;increment pin counter register
adwait1 btfsc ADCON0,2 ;wait for conversion done
goto adwait1 ;not done yet
swapf ADRESH,W ;conversion done, swap result nibbles in to W register
andlw 0Fh ;mask off the upper nibble to limit number to an ascii range
addlw 30h ;convert to ascii character to make it visible to terminal

sendat1 bsf STATUS,RP0 ;select page one
btfss TXSTA,1 ;check transmit status ready to send
goto sendat1 ;if not ready go to try again
bcf STATUS,RP0 ;back to page 0
movwf TXREG ;transmit buffer empty send new data

return
adcnvrt2
movlw 0d1h ;load the initial ADCON0 valu excepting channel select

movwf ADCON0 ;set the new ADCON0 with new channels selected
call wait ;wait about twenty mico seconds
bsf ADCON0,2 ;start conversion
incf Adcnt ;increment pin counter register
adwait2 btfsc ADCON0,2 ;wait for conversion done
goto adwait2 ;not done yet
swapf ADRESH,W ;conversion done, swap result nibbles in to W register
andlw 0Fh ;mask off the upper nibble to limit number to an ascii range
addlw 30h ;convert to ascii character to make it visible to terminal

sendat2 bsf STATUS,RP0 ;select page one
btfss TXSTA,1 ;check transmit status ready to send
goto sendat2 ;if not ready go to try again
bcf STATUS,RP0 ;back to page 0
movwf TXREG ;transmit buffer empty send new data

return
adcnvrt3
movlw 0e9h ;load the initial ADCON0 valu excepting channel select

movwf ADCON0 ;set the new ADCON0 with new channels selected
call wait ;wait about twenty mico seconds
bsf ADCON0,2 ;start conversion
incf Adcnt ;increment pin counter register
adwait3 btfsc ADCON0,2 ;wait for conversion done
goto adwait3 ;not done yet
swapf ADRESH,W ;conversion done, swap result nibbles in to W register
andlw 0Fh ;mask off the upper nibble to limit number to an ascii range
addlw 30h ;convert to ascii character to make it visible to terminal

sendat3 bsf STATUS,RP0 ;select page one
btfss TXSTA,1 ;check transmit status ready to send
goto sendat3 ;if not ready go to try again
bcf STATUS,RP0 ;back to page 0
movwf TXREG ;transmit buffer empty send new data

return

dopwm movf ADRESH,W ;get the A/D conversoin value
movwf CCPR2L ;put valu in to PWM duty cycle register
goto adloop ;
wait movlw 08h ;do await loop of before using a/d convertion
movwf Temp
w1 decfsz Temp
goto w1
return
end ;end program
 

Hi,

That code is clearly not yours so as it comes with so little infomation I'm not going to try and debug all that for you, though your could try changing the Config line of code to this and see if that works.
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _XT_OSC & _WRT_ENABLE_OFF & _LVP_OFF & _DEBUG_OFF & _CPD_OFF

If that does not work then I suggest you use this tutorial and go to example 7.7a which is Usart using the 876A chip, so just change that to 877a and it should work.
http://www.winpicprog.co.uk/pic_tutorial7.htm
 
thank you very much wp100 for your valuable suggestion
its working very well .
seby.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top