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.

need_ help_with_sending_number_as_serial

Status
Not open for further replies.

gladtor_455

Newbie level 5
Joined
May 16, 2009
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,357
hi every one
i am working on a project and i have a proplem i need aa program to send any number as serial from PORTA,0 and between every digit 10 us delay
and the time for every digit is 50 us for example
the number b'11111111' send one in porta,0 for 50 us then clear PORTA,0 for 10 us then continue send the rest with the same system
i wrote a programe but after the 8 digits there is a period about 80 us that PORTA,0 is off then it continue
and for the simulation programe there is message that stack overflow executing call instructionthis is the pograme
if there is anyone can tell me where is the problem and how tocorrect it

; Processor Type PIC16F877A .


LIST P=16F84A
;********************************************************************************************************$
; Include An Additional File In The Program .


#INCLUDE "P16F84A.INC"
;********************************************************************************************************$
; Configuration Register Bits .


__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
;********************************************************************************************************$
; Reset Vector .


org 0x00 ; Processor Reset Vector .

CBLOCK 0X20 ; here block variables
counter
cood_0
d1


ENDC ; blocking ends
GOTO Start ; Go To Beginning Of Program .
;********************************************************************************************************$
; Interrupt Vector .

org 0x04 ; Processor Interrupt Vector .

retfie

;********************************************************************************************************$


;********************************************************************************************************$
; Start of Program .
Start
banksel TRISB
movlw b'11111111'
movwf TRISB
banksel TRISA
clrf TRISA
banksel PORTA
clrf PORTA


movlw b'11111111'
movwf cood_0


PORTB_CHECK
movlw .4
movwf counter

banksel PORTB
btfsc PORTB,0
call function_0


goto PORTB_CHECK


function_0
btfss cood_0,0
call send_zero
call send_one

send_zero
banksel PORTA
BCF PORTA,0
call delay_50
rrf cood_0,f
decfsz counter,f
goto function_0
clrf PORTA
bcf STATUS,0
goto PORTB_CHECK



send_one
banksel PORTA
BSF PORTA,0
rrf cood_0,f
call delay_50
bcf PORTA,0
call delay_10
decfsz counter, 1
goto function_0
clrf PORTA
goto PORTB_CHECK



delay_50
movlw 0x0d
movwf d1
Delay_3
decfsz d1, f
goto Delay_3
return

delay_10
goto $+1
goto $+1
goto $+1
goto $+1
return



LOOP GOTO LOOP

;********************************************************************************************************$



END ; Directive 'end of program'.

 

Attachments

  • pic.jpg
    pic.jpg
    184 KB · Views: 3

zemanj

Newbie level 2
Joined
Jan 17, 2011
Messages
2
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Activity points
1,289
Good day

main problem is in if you are using instruction call xxxx, that at end this routines must by instruction return. On yours code using call/goto, next will be stack overloaded!
 

gladtor_455

Newbie level 5
Joined
May 16, 2009
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,357
any one can correct my program
i am new to pic
 

zemanj

Newbie level 2
Joined
Jan 17, 2011
Messages
2
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Activity points
1,289
any one can correct my program
i am new to pic

I am thinking, is not good correct program, because here is more problems, will be good write all the new program with using delays routines!
 

kapilddit

Junior Member level 1
Joined
Jan 2, 2010
Messages
16
Helped
8
Reputation
16
Reaction score
6
Trophy points
1,283
Location
Mumbai
Activity points
1,434
I have not gone through you code in much details,as it was in assembly.... but still i m trying to do best whatever i have experience....

I am thinking this as a syncronizing issue....

As u said u are getting more delay somewhere after one cycle... mean timing generation is not proper...
mean your delay generation is not proper..
Mean either there is problem in delay generation or ..... (u never come to know wht controller is executint at what time...)
better to use interrupt for such kind of precise generation of timer... bCoz form this u need to debug the issue step by step...
if you have debugger then u can do that...
or one more thing u can do is that put LED on off statement in timer routine......by that way u can minimize the scope of the issue....

If this works then give thumsup....
kapilddit
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top