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.

Problem with receiving bytes at a time (on/off led)

Status
Not open for further replies.

candy66

Newbie level 6
Joined
Dec 17, 2007
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,363
Receiving bytes

Hey guys i encountered a problem right now...i need to on/off led when i received few btyes at a time(for example, when i recieved 3 bytes, the led should turn" on off and on" agn.Can any one help?Now i only manage to turn on led when i received a byte and off the led when i received the next byte.This is my codes:

uart_ready
btfss PIR1,RCIF ;; 5
goto uart_ready ;if not ready, wait...
movf RCREG,W ;recover uart data
xorwf LATB ;light led
bsf INTCON,7 ;re-enable interrupts

Thanks
 

Receiving bytes

you should use the timer so you won't waste the cycles. if you really cannot use timers - you need to put some delay loops between changing the state of the led

you should then add the counter in your uart ISR - it will be just increased once with every char. then in the main program you should compare this to some literal (i.e. 3). if the values match, you should clear the counter and start:
- the routine that does the blinking stuff with delays
- the timer which will handle this blinking for you (the timer ISR does nothing more than increment some other counter, and toggle the led. if the counter matches some constant, the timer switches itself off - you need to toggle the led 3 times, so again compare it with 3.

gl

0x41 0x56 0x45!!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top