My PIC program won't work! Plz Help?!


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2010
    Posts
    2

    Unhappy My PIC program won't work! Plz Help?!

    Hey guys, i wrote a program in assembly for the 80C51 and it worked but now i have to write the same one for the PIC16F84A in assembly language, and it just wont work. Can someone figure out what mistakes i did?
    This program controls one 7-segment display to count from 0-9 whilst the other 7-segment display to count from 9-0 at the same time.
    Thanks for any help.

    LIST P=16F84
    INCLUDE "P16F84.INC"
    __CONFIG _XT_OSC & _PWRTE_ON & _WDT_OFF & _CP_OFF
    RADIX HEX
    ;
    PORTB EQU 0x06
    PORTA EQU 0x05
    ;
    R1 EQU 0x0C
    R2 EQU 0x0D
    R3 EQU 0x0E
    ;
    ORG 0
    ;
    MOVLW 0x1F
    TRIS PORTA
    ;
    MOVLW 0x00
    TRIS PORTB
    ;
    CLRF PORTA
    CLRF PORTB
    ;
    REPEAT: MOVLW 0x0F
    MOVFW PORTB
    ;
    MOVLW 0x0F
    MOVFW PORTB
    ;
    PA_0: BTFSC PORTA,0
    GOTO PA_0
    ;
    CALL DISP
    BTFSC PORTA,0
    GOTO PA_0
    ;
    MOVLW 0x06
    MOVFW PORTB
    MOVLW 0xF6
    MOVFW PORTB
    ;
    CALL DISP
    ;
    MOVLW 0xDA
    MOVFW PORTB
    MOVLW 0xFE
    MOVFW PORTB
    ;
    CALL DISP
    ;
    MOVLW 0xF2
    MOVFW PORTB
    MOVLW 0xE0
    MOVFW PORTB
    ;
    CALL DISP
    ;
    MOVLW 0x66
    MOVFW PORTB
    MOVLW 0xBE
    MOVFW PORTB
    ;
    CALL DISP
    ;
    MOVLW 0xB6
    MOVFW PORTB
    MOVLW 0xB6
    MOVFW PORTB
    ;
    CALL DISP
    ;
    MOVLW 0xBE
    MOVFW PORTB
    MOVLW 0x66
    MOVFW PORTB
    ;
    CALL DISP
    ;
    MOVLW 0xE0
    MOVFW PORTB
    MOVLW 0xF2
    MOVFW PORTB
    ;
    CALL DISP
    ;
    MOVLW 0xFE
    MOVFW PORTB
    MOVLW 0xDA
    MOVFW PORTB
    ;
    CALL DISP
    ;
    MOVLW 0xF6
    MOVFW PORTB
    MOVLW 0x60
    MOVFW PORTB
    ;
    CALL DISP
    ;
    GOTO REPEAT
    ;
    ;
    DISP: MOVLW 1
    MOVFW R3
    LP3: MOVLW 0x0F
    MOVFW R2
    LP2: MOVLW 0x0F
    MOVFW R1
    LP1: DECFSZ R1
    GOTO LP1
    DECFSZ R2
    GOTO LP2
    DECFSZ R3
    GOTO LP3
    ;
    RETURN
    ;
    END
    ;
    ;At blast time, select:-
    ;
    ;memory unprotected
    ;watchdog timer disables
    ;standard crystal (4MHz)
    ;power up timer on

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Question

    Hi, Zammi

    first : note here is NOT the best place to ask about Assembler ... much better about PicBasic ... !!!

    with my limited skills, ...

    I really wonder what you try to do with all those lines groups ... :

    Code:
    MOVLW 0x06
    MOVFW PORTB
    MOVLW 0xF6
    MOVFW PORTB
    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Mar 2010
    Posts
    2


    Did you find this post helpful? Yes | No

    Default

    the aim of my project was to change the 80C51 code program into the PIC assembly language..the original program in assembly language og the 80C51 was this:

    dis1 equ P1.0
    dis2 equ P1.1
    ;
    org 00h
    ljmp main

    org 30h;
    main: mov r2,#0FCh
    mov r3,#0FCh
    acall disp
    mov r2,#060h
    mov r3,#0F6h
    acall disp;
    mov r2,#0DAh
    mov r3,#0FEh
    acall disp;
    mov r2,#0F2h
    mov r3,#0E0h
    acall disp;
    mov r2,#066h
    mov r3,#0BEh
    acall disp;
    mov r2,#0B6h
    mov r3,#0B6h
    acall disp
    mov r2,#0BEh
    mov r3,#066h
    acall disp;
    mov r2,#0E0h
    mov r3,#0F2h
    acall disp;
    mov r2,#0FEh
    mov r3,#0DAh
    acall disp;
    mov r2,#0F6h
    mov r3,#060h
    acall disp;
    sjmp main;

    disp: mov r4,#0ffh;
    loop: mov r5,#0f0h;
    loop1: mov a,r2;
    clr dis2;
    cpl a;
    mov P2,a;
    setb dis1;
    nop;
    nop;
    mov a,r3;
    clr dis1;
    cpl a;
    mov P2,a;
    setb dis2;
    djnz r5,loop1;
    djnz r4,loop;
    clr dis1;
    clr dis2;
    ret;
    end

Similar Threads

  1. Replies: 14
    Last Post: - 8th November 2010, 11:50
  2. Simple Blink program doesnt work.
    By sccoupe in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 1st March 2009, 20:30
  3. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  4. Replies: 14
    Last Post: - 26th September 2007, 05:41
  5. Will This program work
    By deepgfishing in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 22nd June 2007, 22:45

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts