Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Forums > Electronic Projects Design/Ideas/Reviews


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.

Reply
 
Thread Tools Display Modes
Old 10th May 2008, 08:21 PM   (permalink)
Default pic programing

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
iceberg25 is offline   Reply With Quote
Old 10th May 2008, 08:32 PM   (permalink)
Default

Quote:
Originally Posted by iceberg25
stop movlw 00h
movwf PORTB
goto turn
turn movlw 01h
movfw PORTB
The last line from these few should read

movwf PORTB

There may be other faults.
Diver300 is offline   Reply With Quote
Old 11th May 2008, 02:18 PM   (permalink)
Default

who can design for me an 8-digit frequency counter using pic16f684 , im struggling.
vectorsd is offline   Reply With Quote
Old 11th May 2008, 03:05 PM   (permalink)
Default

Quote:
Originally Posted by vectorsd
who can design for me an 8-digit frequency counter using pic16f684 , im struggling.
How much are you paying?
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is offline   Reply With Quote
Old 12th May 2008, 06:56 PM   (permalink)
Default

Quote:
Originally Posted by Diver300
The last line from these few should read

movwf PORTB

There may be other faults.
i not really get what you want to tell me.......
iceberg25 is offline   Reply With Quote
Old 12th May 2008, 06:57 PM   (permalink)
Default

Quote:
Originally Posted by vectorsd
who can design for me an 8-digit frequency counter using pic16f684 , im struggling.
u may open a new post to ask.thanks
iceberg25 is offline   Reply With Quote
Old 12th May 2008, 09:04 PM   (permalink)
Default

Quote:
Originally Posted by vectorsd
who can design for me an 8-digit frequency counter using pic16f684 , im struggling.
I'll do it for a fee... Lets say $100 per hour based on an 8 hour day.... Shouldn't take more than a couple of weeks to get the code, schematic and PCB design sorted.... And I'll retain the copyright and licencing rights to the design... Still want someone to do the work for you???
__________________
====
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!!!
Shax is offline   Reply With Quote
Old 14th May 2008, 03:59 PM   (permalink)
Default

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.
tyru is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
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



All times are GMT. The time now is 01:45 PM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.