Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Data Tables using pic 16F84A

Status
Not open for further replies.

saviourm

Junior Member level 3
Joined
Apr 28, 2011
Messages
30
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,519
Dear all,

I am learning the pic ,can someone help me?
I have the following program in assembly.My problem is ,when I am tyring to display the value H'0001' and H'0002' on PORTB via set of Leds the value displayed is incorrect. But the other values on the program are dispalyed correctly .I tried to put the values in HEX,Binary and Decimal but the same result occured !


_PWRTE_ON EQU H'3FF7'
_PWRTE_OFF EQU H'3FFF'
_WDT_ON EQU H'3FFF'
_WDT_OFF EQU H'3FFB'
_LP_OSC EQU H'3FFC'
_XT_OSC EQU H'3FFD'
_HS_OSC EQU H'3FFE'
_RC_OSC EQU H'3FFF'

__CONFIG _CP_OFF & _PWRTE_OFF & _WDT_OFF & _XT_OSC
TRISA equ H'0085'
PORTA equ H'0005'
COUNT1 equ H'0008'
COUNT2 equ H'0009'
STATUS equ H'0003'
PORTB equ H'0006'
TRISB equ H'0086'
PCL equ H'0002'
PCLATH equ H'000A'

org H'0010'
bsf STATUS,5
movlw H'0000'
movwf TRISB
bcf STATUS,5
start movlw H'0004' ;value to be displayed
Call Table
movwf PORTB
Table addwf PCL
retlw H'0012'
retlw H'0008'
retlw H'0015'
retlw H'0003'
retlw H'0001'
retlw H'0002'
return
end
 

I am using the MPASWIN to assemble and programing using a Velleman Kit(programmer and experiment board).Manual attached including circuit. Thankyou for your support!
 

Attachments

  • Manual_K8048_UK (rev3).pdf
    492.1 KB · Views: 79

Why set your origin to 0x0010 and not 0x0000? Depending on the assembler you're using, you can save yourself some typing and setup by using assembler directives:


i.e. MPASM

list p=16F84A ;tell assembler what chip we are using - a must
#include "P16F84A.inc" ;setup common mnemonics with equ - like your equ's in your program

Anyway, here's a nice tutorial on lookup tables using PIC 16F similar to your program:

Checkout Tutorial 1.9 Lookup Tables

Checkout PATTERN.ASM

These tips should get your started in the right direction.

---------- Post added at 20:13 ---------- Previous post was at 20:10 ----------

MPASWIN? Is this the assembler that comes with Microchip's IDE, MPLAB? MPASM?

---------- Post added at 20:21 ---------- Previous post was at 20:13 ----------

It appears you're using MPASM, you'll need a copy of the user guide, lots of tips and examples:

MPASM™ Assembler, MPLINK™ Object Linker MPLIB™ Object Librarian User’s Guide
 
MPASWIN is a micro chip program an I also tried another pic the 16F627 , result the same.
 

I looked up MPASWIN, it installs MPASM. Download the user guide from the link above and use some of the examples for in the guide as a template.

The PIC16F84A is fine to get started. Download its datasheet from Microchip:

PIC16F84A Data Sheet

PIC 16F84A Page:

PIC16F84A

Remember, different assemblers require different directives, so use the LIST and #INCLUDE directives in the above example.

I'll take a look at your code and see if I can spot any glaring mistakes.
 
Hex, binary and decimal are all the same to a register.
This code will crash with a stack underflow, reset, and crash again.

Code:
       org    H'0010'

        bsf    STATUS,5
        movlw  H'0000'
        movwf  TRISB
        bcf    STATUS,5

start   movlw  H'0004'        ;value to be displayed
        Call   Table
        movwf  PORTB

Table   addwf  PCL
        retlw  H'0012'
        retlw  H'0008'
        retlw  H'0015'
        retlw  H'0003'
        retlw  H'0001'
        retlw  H'0002'
        return
 
        end

You need a some kind of a loop.

Code:
       org    H'0000'        ;Pic reset vector

        bsf    STATUS,5
        movlw  H'0000'
        movwf  TRISB
        bcf    STATUS,5

start   movlw  H'0004'         ;value to be displayed
        Call   Table
        movwf  PORTB

        goto   start		;Loop!	

Table   addwf  PCL
        retlw  H'0012'
        retlw  H'0008'
        retlw  H'0015'
        retlw  H'0003'
        retlw  H'0001'
        retlw  H'0002'
        return
 
        end
 
Many thanks!!!!
problem solved!!!
The problem was the loop ,Good Night
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top