![]() |
![]() |
![]() |
|
|
|||||||
| Electronic Projects Design/Ideas/Reviews Are you building an electronic project or want to? Maybe you need some assistance? Come and submit your electronic questions here and let our experienced members find a solution. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
New Member
|
hi ~all.
i am trying to program something to microchip pic16f877a by using mplab,who can help me check whether my script can run in pic or not? help me to correct if got any error. thanks. ;************************************************* ********************* ; * ; Filename: xxx.asm * ; Date: * ; File Version: * ; * ; Author: * ; Company: * ; * ; * ;************************************************* ********************* ; * ; Files Required: P16F877A.INC * ; * ;************************************************* ********************* ; * ; Notes: * ; * ;************************************************* ********************* list p=16f877A ; list directive to define processor #include <p16f877A.inc> ; processor specific variable definitions __CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _RC_OSC & _WRT_OFF & _LVP_ON & _CPD_OFF ORG 0x000 goto main main STATUS equ 03h TRISA equ 85h TRISB equ 86h PORTA equ 05h PORTB equ 06h movlw 02h movwf STATUS movlw 03h movwf TRISA movlw fch movwf TRISB clrf STATUS start btfss PORTA,0 btfsc PORTA,1 goto stop movlw 03h movwf PORTB goto start stop movlw 00h movwf PORTB goto turn turn movlw 01h movfw PORTB btfsc PORTA,0 btfss PORTA,1 goto start goto turn |
|
|
|
|
|
(permalink) | |
|
Experienced Member
|
Quote:
movwf PORTB There may be other faults. |
|
|
|
|
|
|
(permalink) |
|
New Member
|
who can design for me an 8-digit frequency counter using pic16f684 , im struggling.
|
|
|
|
|
|
(permalink) | |
|
Experienced Member
|
Quote:
|
|
|
|
|
|
|
(permalink) | |
|
New Member
|
Quote:
|
|
|
|
|
|
|
(permalink) | |
|
New Member
|
Quote:
|
|
|
|
|
|
|
(permalink) | |
|
Experienced Member
|
Quote:
__________________
==== Shax. ==== A bus station is where a bus stops... A train station is where a train stops... On my desk I have a work station... Nuff Sed!!! |
|
|
|
|
|
|
(permalink) |
|
New Member
|
list p=16f877A ; list directive to define processor
#include <p16f877A.inc> ; processor specific variable definitions __CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _RC_OSC & _WRT_OFF & _LVP_ON & _CPD_OFF ORG 0x000 goto main Main STATUS equ 03h ; not needed, defined in INC statment TRISA equ 85h ; not needed TRISB equ 86h ; not needed PORTA equ 05h ; not needed PORTB equ 06h ; not needed clrf PORTB ; clear the ports clrf PORTA movlw 02h movwf STATUS ; goto Bank 1 movlw 03h movwf TRISA ;set Port A to 00000011 (RA0 and RA1 are inputs) movlw fch movwf TRISB ;set Port B 11111100 (RB0 and RB1 are outputs) clrf STATUS ; goto Bank 0 Start btfss PORTA,0 ; check input pin RA0 and skip if 1 btfsc PORTA,1 ; check input pin RA1 and skip if 0 goto stop movlw 03h movwf PORTB ;set the outputs pins RB0 and RB1 to 1 goto start Stop movlw 00h movwf PORTB ;clear Port B goto turn ;not realy needed since it will drop thru anyways Turn movlw 01h movwf PORTB ;set the outputs pin RB0 to 1 btfsc PORTA,0; check input pin RA0 and skip if 0 btfss PORTA,1; check input pin RA1 and skip if 1 goto start goto turn This would be easier to check if we knew what this program is intended to do. By the subroutine names, it looks like you want to start, stop and turn something. Maybe two motors on a robot?. However, the stop routine runs imediately into the turn routine, which I don't think is what u want. Also note that if RA0 and RA1 pins are switches, there is no debounce routine to wait for the switch state to settle before calling a subroutine. Last edited by tyru; 14th May 2008 at 04:16 PM. |
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| Can a PIC be a bit faulty? | bigal_scorpio | General Electronics Chat | 20 | 10th April 2008 08:52 PM |
| Quik PIC Programming kit | Krumlink | General Electronics Chat | 5 | 27th January 2008 11:27 PM |
| Capturing and reproducing audio with a PIC | Fred.Amoson | Micro Controllers | 14 | 14th December 2007 08:21 PM |
| Problems switchin relay with PIC | Andy1845c | General Electronics Chat | 5 | 17th November 2007 06:13 PM |
| High ADC sampling rate PIC, 18F needed? | bananasiong | Micro Controllers | 24 | 28th October 2007 12:13 PM |