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.

Mplab Source Code (Assembly) compiled but did not run in proteus

Status
Not open for further replies.

khatus

Member level 3
Member level 3
Joined
Oct 7, 2017
Messages
64
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Activity points
1,753
Hello guys this is the code for blink led in mplab ide using assembly language. But unfortunately, when i tried to simulate it in proteus it did not run
Here is my complete code
Code:
#include "p16f84a.inc"

; CONFIG
; __config 0x3FFF
 __CONFIG _FOSC_EXTRC & _WDTE_ON & _PWRTE_OFF & _CP_OFF
    
    
    RES_VECT  CODE    0x0000            ; processor reset vector
    GOTO    START                   ; go to beginning of program

; TODO ADD INTERRUPTS HERE IF USED

MAIN_PROG CODE                      ; let linker place main program


 
   STATUS equ 03h;
   TRISA  equ 85h;
   PORTA  equ 05h;
   COUNT1 equ 08h;
   COUNT2 equ 09h;
 ;****set up the ports****

   BSF STATUS, 5;
   MOVLW 00h;
   MOVWF TRISA;
   BCF STATUS,5;
   ;*****TURN the led on*********
START
   MOVLW 02h
   MOVWF PORTA;
  
LOOP1
   DECFSZ COUNT1,1;
   GOTO LOOP1;
   DECFSZ COUNT2,1;
   GOTO LOOP1;
;***Delay finished, now turn the led off***
   MOVLW 00h;
   MOVWF PORTA;
;***ADD another delay***
LOOP2
    DECFSZ COUNT1,1;
    GOTO LOOP2;
    DECFSZ COUNT2,1;
    GOTO LOOP2;
;****Get back to the start of the program;
    GOTO START;
    
 
  
                          
END
Here is the simulation result in mplab

mplab.PNG


And here is my proteus simulation result.
blink_led_assembly.PNG

What is the problem??
 

Solution
Without looking further, you have the oscillator configured for external RC operation but a crystal across the oscillator pins. It will never run in that configuration, either use an RC combination or change the oscillator setting in the configuration fuses.

Brian.
Without looking further, you have the oscillator configured for external RC operation but a crystal across the oscillator pins. It will never run in that configuration, either use an RC combination or change the oscillator setting in the configuration fuses.

Brian.
 

Solution
Proteus allow working either in Release or Debug mode, where the last one give you a lot of resources to investigate, such as breakpoints.

Anyway, are you attentive to manage registers bank before handling them ? I don't remember the syntax, but at a glance seems like not having been done, maybe unnecessary in your case.
 

Thanks, it is solved. Here is the updated code,
Code:
#include "p16f84a.inc"

; CONFIG
; __config 0xFFFD
 __CONFIG _FOSC_XT & _WDTE_ON & _PWRTE_OFF & _CP_OFF
    
    
    RES_VECT  CODE    0x0000            ; processor reset vector
    GOTO    START                   ; go to beginning of program

; TODO ADD INTERRUPTS HERE IF USED

MAIN_PROG CODE                      ; let linker place main program

START
 
   STATUS equ 03h;
   TRISA  equ 85h;
   PORTA  equ 05h;
   COUNT1 equ 08h;
   COUNT2 equ 09h;
 ;****set up the ports****

   BSF STATUS, 5;
   MOVLW 00h;
   MOVWF TRISA;
   BCF STATUS,5;
   ;*****TURN the led on*********
REPEAT
   MOVLW 02h
   MOVWF PORTA;
  
LOOP1
   DECFSZ COUNT1,1;
   GOTO LOOP1;
   DECFSZ COUNT2,1;
   GOTO LOOP1;
;***Delay finished, now turn the led off***
   MOVLW 00h;
   MOVWF PORTA;
;***ADD another delay***
LOOP2
    DECFSZ COUNT1,1;
    GOTO LOOP2;
    DECFSZ COUNT2,1;
    GOTO LOOP2;
;****Get back to the start of the program;
    GOTO REPEAT;
 
 END
--- Updated ---

 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top