Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Assembly Knight Rider Program

Status
Not open for further replies.
The reason your "newest" code fails is the bank selection is wrong

BCF STATUS, RP1 and BCF STATUS, RP0 = bank 1
BCF STATUS, RP1 and BSF STATUS, RP0 = bank 2

Here is the exact code I used
Code:
  list   p=16F870     
   include "P16F870.inc"   

   __config 0xFF3A
c1   equ 20h
c2   equ 21h
c3   equ 22h
dummy  equ 28h

  org 00h
  goto main


main
  BANKSEL STATUS
  bsf STATUS, C

  BANKSEL TRISB
  movlw b'00000000'
  movwf TRISB
   
  BANKSEL PORTB
  movlw b'00000001'
  movwf PORTB
   
  loop
  rlf PORTB
  call _delay_1s
   
  GOTO loop  ; loop forever
_delay_1s
   
   
  movlw  0x2c
  movwf  c1
  movlw  0xE7
  movwf  c2
  movlw  0x0B
  movwf  c3
_delay_1s_0
  decfsz  c1, f
  goto  $+2
  decfsz  c2, f
  goto  $+2
  decfsz  c3, f
  goto  _delay_1s_0

  ;3 cycles
  goto  $+1
  nop

  ;4 cycles (including call)
  return
  END
 
here is a knight rider program done in Swordfish. Pretty sure it will work??
I still am unpacking my electronic stuff and yet to locate my programmer. I did find a knight rider program done in Assembly here http://www.bradsprojects.com/category/tutorials/

Device = 18F1220

Clock = 20

Config MCLRE = Off



Include "InternalOscillator.bas"



// Connect each set of LEDs to PORTB (from RB0 to RB7)



Sub RightToLeft()

Dim i As Byte

For i = 0 To 7

PORTB.Bits(i) = 1

DelayMS(500)

PORTB.Bits(i) = 0

Next

End Sub



Sub LeftToRight()

Dim i As Byte

For i = 7 To 0 Step -1

PORTB.Bits(i) = 1

DelayMS(500)

PORTB.Bits(i) = 0

Next

End Sub



// program start...

TRISB = %00000000 And TRISB // make RB0-RB7 outputs

PORTB = %00000000 And PORTB // make all LED outputs low



While True

LeftToRight

RightToLeft
 
Status
Not open for further replies.

Latest threads

Back
Top