PIC Port B Spinnt

OP #516132
Lesenswert?
• ▲
▼
Hi,

ich hab da mal wieder ein Problem. 16F84A
Ich möchte gerne ein ganz einfaches Lauflicht haben, aber leider macht 
mir der Port B zu schaffen.

Port B0/1 wollen einfach nicht mit machen. Der rest arbeitet 
einwandfrei.

Muss ich irgend wo noch was mit dem Interrupt umstellen.
ich find einfach keine Lösung.

Habe das Programm auf 2 PIC´s laufen lassen und es ist auf beiden das 
selbe problem.

Sollte jemand einen 16F84A rumliegen haben kann er ja mal probieren ob 
bei ihm das selbe passiert.

schon mal danke für eure Hilfe.



;**********************************************************************
;   This file is a basic code template for assembly code generation   *
;   on the PIC16F84A. This file contains the basic code               *
;   building blocks to build upon.                                    *
;                                                                     *
;   If interrupts are not used all code presented between the ORG     *
;   0x004 directive and the label main can be removed. In addition    *
;   the variable assignments for 'w_temp' and 'status_temp' can       *
;   be removed.                                                       *
;                                                                     *
;   Refer to the MPASM User's Guide for additional information on     *
;   features of the assembler (Document DS33014).                     *
;                                                                     *
;   Refer to the respective PIC data sheet for additional             *
;   information on the instruction set.                               *
;                                                                     *
;   Template file built using MPLAB V4.00 with MPASM V2.20 and        *
;   MPLINK 1.20 as the language tools.                                *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Filename:      Lauflicht-BK.asm                                  *
;    Date:          07.03.2007                                        *
;    File Version:  1.0                                               *
;                                                                     *
;    Author:        Jens Huettenrauch                                 *
;    Company:       Selfmade                                          *
;                                                                     *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Files required:                                                  *
;                                                                     *
;                                                                     *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Notes:                                                           *
;                                                                     *
;                                                                     *
;                                                                     *
;                                                                     *
;**********************************************************************


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

  __CONFIG   _CP_OFF & _WDT_OFF & _PWRTE_OFF & _HS_OSC

; '__CONFIG' directive is used to embed configuration data within .asm 
file.
; The lables following the directive are located in the respective .inc 
file.
; See respective data sheet for additional information on configuration 
word.




;***** VARIABLE DEFINITIONS (examples)

zeit250  Equ  0x22    ; Zähler für Warteschleife
zeit1  Equ  0x23    ; Zähler für Warteschleife
lauf  Equ 0x24    ; Speicherzelle fuer Lauflicht

;**************************************************************
; Organiesirung

  org    0x00    ; Hier startet der Prozessor
  goto  Main    ; Springe zum Hauptprogramm

  org    0x04    ; Hier startet der Interupt wenn aktiv

;**********************************************************************
; Hauptprogramm
  org    0x10
Main          ; los gehts mit dem Programm

; Port B auf Ausgabe stellen

Init
  bsf     STATUS, RP0  ; auf Bank 1 umschalten
  movlw  B'00000000'  ; W mit 0 Fuettern
  movwf  TRISB    ; Lade in Initregister B Bank 1
  bcf     STATUS, RP0  ; auf Bank 0 zurückschalten
  clrf  PORTB    ; alle LEDs ausschalten
  clrf  lauf    ; Speicherzelle auf def. Zustand bringen
;  clrz
;  clrc

; 1. LED einschalten
Init1
  movlw  B'00000001'
  movwf  lauf
  clrz
  clrc
Lauf1
  movfw  lauf
  movwf  PORTB
  call  Wait250
  bz    Init2
  rlf    lauf
  goto  Lauf1
Init2
  movlw  B'10000000'
  movwf  lauf
  clrz
  clrc
Lauf2
  movfw  lauf
  movwf  PORTB
  call  Wait250
  bz    Init1
  rrf    lauf
  goto  Lauf2



;**********************************************************
; Warteschleife 250 ms

Wait250          ; 250 ms Pause
  movlw  D'250'    ; Zeitkonstante für 250ms
  movwf  zeit250    ; Speicherzelle für 1 ms Multiplikator
;**********************************************************
; Warteschleife 1 ms
Wait1          ; 1 ms Pause
    movlw   .249    ; Zeitkonstante für 1ms
        movwf   zeit1  ; Speicherzelle für Warteschleife
Wai2    nop        ; Warte einen Takt ab
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    decfsz  zeit1,F  ; verringere um eins
    goto   Wai2  ; Ist 1ms vorbei
    decfsz   zeit250,F; erringere um eins
    goto   Wait1  ; Ist 250ms vorbei
    retlw 0      ; Springe zurück zum Call

  end
;*********************************************************************

Antwort schreiben

Hinweis: der ursprüngliche Beitrag ist mehr als 6 Monate alt. Bitte hier nur auf die ursprüngliche Frage antworten, für neue Fragen einen neuen Beitrag erstellen.

Formatierung
  • [c]C-Code[/c]
  • [code]Code in anderen Sprachen, ASCII-Zeichnungen[/code]
  • [math]Formel in LaTeX-Syntax[/math]
  • [[Titel]] – Link zu einem Artikel
  • Verweis auf einen anderen Beitrag: Rechtsklick auf dessen Beitrags-ID (#8078628), „Adresse kopieren“, in den Text einfügen

Mehr zur Formatierung

Längeren Sourcecode als Anhang, nicht in den Text. JPG nur für Fotos und Scans; Zeichnungen und Screenshots als PNG oder GIF. Siehe Bildformate.

Schon registriert? Anmelden

Wird nicht angezeigt. Wir schicken dir einen Link; sobald du damit bestätigst, erscheint dein Beitrag.

Mit dem Abschicken legst du einen kostenlosen Account an und erkennst die Nutzungsbedingungen und die Datenschutzerklärung an.