![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| Hey, i have 8 leds on PORTB i want to light them alternately, and then turn off like 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 1 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 1 0 0 0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 0 1 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 how can i do that with PIC ASM ? thx for the help | |
| |
| | (permalink) |
| Read my tutorials, you can make any pattern you like. | |
| |
| | (permalink) |
| I thought of a simple way that just complements the carry flag. Code: clrf PORTB ;start all off bsf STATUS,C ;set carry flag Loop rrf PORTB ;shift carry into port b movlw 1 ;Bit 0 = carry flag xorwf STATUS,W ;complement carry flag movwf STATUS ;write it back call Delay ;must not corrupt the carry flag. goto Loop ;do it all again Delay movlw 0x1F movwf d1 movlw 0x4F movwf d2 Delay_0 decfsz d1, f goto $+2 decfsz d2, f goto Delay_0 return Can you tell, I was bored. Mike. | |
| |
| | (permalink) |
| The code needed to do this is so elementary. Configuring the TRISB, interrupts and timers is more involved. How did you get pass the thicket yet drown in the puddles. | |
| |
| | (permalink) | |
| Quote:
Unless I'm mistaken, can't you eliminate the "setc" instruction (bsf STATUS,C) before the loop? No need to preserve Carry in the delay routine for this example; Code: ;
clrf PORTB ;
Loop
clrc ;
btfss PORTB,0 ;
setc ;
rrf PORTB,F ;
call Delay ;
goto Loop ;
; Last edited by Mike, K8LH; 8th November 2007 at 06:11 PM. | ||
| |
| | (permalink) |
| This code works properly: Code: list p=16f84 include "p16f84.inc" ax equ 0x10 bx equ 0x12 Reset_Vector code 0x000 goto start code 0x002A start clrf PORTB bsf STATUS,5 clrf TRISB bcf STATUS,5 movlw d'8' movwf ax movlw d'8' movwf bx FIRST bsf STATUS,0 rrf PORTB,1 decfsz ax,1 goto FIRST LAST bcf STATUS,0 rrf PORTB,1 decfsz bx,1 goto LAST LOOP goto LOOP end | |
| |
| | (permalink) |
| The above methods are superb.Nice work. But some people do it from calling a Table which can load many patterns which is require. But the OP satisfied with the above method. | |
| |
| | (permalink) |
| Can anyone tell me how can i make 0.1 second delay here ? i mean 1 0 0 0 0 0 0 0 (0.1 s later) 1 1 0 0 0 0 0 0 (0.1 s later) 1 1 1 0 0 0 0 0 (0.1 s later) 1 1 1 1 0 0 0 0 .. .. .. 0 0 0 0 0 0 1 1 (0.1 s later) 0 0 0 0 0 0 0 1 (0.1 s later) 0 0 0 0 0 0 0 0 i want to use this delay in that code : Code: list p=16f84 include "p16f84.inc" ax equ 0x10 bx equ 0x12 Reset_Vector code 0x000 goto start code 0x002A start clrf PORTB bsf STATUS,5 clrf TRISB bcf STATUS,5 movlw d'8' movwf ax movlw d'8' movwf bx FIRST bsf STATUS,0 rrf PORTB,1 decfsz ax,1 goto FIRST LAST bcf STATUS,0 rrf PORTB,1 decfsz bx,1 goto LAST LOOP goto LOOP end | |
| |
| | (permalink) |
| Like I said much earlier in this thread, check my tutorials, where I use the Delay Code Generator found on the PICList to generate the delays - or you could just take the subroutines from my tutorials. | |
| |
| | (permalink) |
| Delay code generate gave this routine for 1 second. Code: Del1s movlw 0x08 movwf d1 movlw 0x2F movwf d2 movlw 0x03 movwf d3 Delay_0 decfsz d1, f goto $+2 decfsz d2, f goto $+2 decfsz d3, f goto Delay_0 ;3 cycles goto $+1 nop return | |
| |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| Title | Starter | Forum | Replies | Latest |
| PIC ASM - Summation two 16 bit numbers (16f84) | byrusber | Micro Controllers | 10 | 28th October 2007 09:41 PM |
| High ADC sampling rate PIC, 18F needed? | bananasiong | Micro Controllers | 24 | 28th October 2007 01:13 PM |
| PIC output pin keeps going low | Endicron | Micro Controllers | 12 | 1st October 2007 09:15 AM |
| LED sensor help | flemmard | Micro Controllers | 13 | 14th September 2007 07:07 PM |
| P channel FETs vs N channel FETs for LED Matrix applications ?? | tdg8934 | General Electronics Chat | 3 | 9th September 2007 06:17 PM |