Discussion in "Project Help" started by    rogermado    Apr 25, 2020.
Sat Apr 25 2020, 03:59 PM
#1
Hello everyone,

sorry in advance if i'm not in the right section of the forum to ask this question :

Well, i'm making a school project based on the PIC16F877A. And i have already written the code in MPLabx IDE 5.35. I've simulated it on MPLabX and it worked just fine! the problem is when i use the software "REAL PIC SIMULATOR" i'm not able to make it work. The 7seg display stucks and the results i'm waiting are pretty weird and impredictable. By the way, i build the code i wrote on MPLAB in a hex file then i opened it on Real Pic Simulator.I wonder if there is a "good" way to go from MBLab to Real pic simulator with no problems along the way. Thank you very much in advance for your help,

RogerMado
Sat Apr 25 2020, 05:42 PM
#2
Some simulators handle displays better than others.
If you post as much of your code and circuit diagram as possible
we can try it in "Real Pic Simulator" and Proteus.

Meanwhile try writing test code to do very simple things
such as displaying just one character.
First find what works.. then add to it.
Sun Apr 26 2020, 01:53 AM
#3
@ExperimenterUK, thanks for your reply. You'll find the code below. thanks again RogerMado





;**********************************************************************
; This file is a basic code template for assembly code generation *
; on the PIC16F877A. This file contains the basic code *
; building blocks to build upon. *
; *
; Refer to the MPASM User's Guide for additional information on *
; features of the assembler (Document DS33014). *
; *
; Refer to the respective PIC data sheet for additional *
; information on the instruction set. *
; *
;**********************************************************************
; *
; 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

; '__CONFIG' directive is used to embed configuration data within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.






;***** VARIABLE DEFINITIONS
w_temp EQU 0x7D ; variable used for context saving
status_temp EQU 0x7E ; variable used for context saving
pclath_temp EQU 0x7F ; variable used for context saving

CNT_7_SEG EQU 0X24






ORG 0x000 ; processor reset vector
nop ; nop required for icd
goto main ; go to beginning of program
ORG 0x004 ; interrupt vector location
movwf w_temp ; save off current W register contents
movf STATUS,w ; move status register into W register
movwf status_temp ; save off contents of STATUS register
movf PCLATH,w ; move pclath register into w register
movwf pclath_temp ; save off contents of PCLATH register
test_1
BTFSS INTCON,INTF
goto test_2
call service_interrupt_2
test_2
BTFSS INTCON,RBIF
goto Sortir
call service_interrupt
Sortir
movf pclath_temp,w ; retrieve copy of PCLATH register
movwf PCLATH ; restore pre-isr PCLATH register contents
movf status_temp,w ; retrieve copy of STATUS register
movwf STATUS ; restore pre-isr STATUS register contents
swapf w_temp,f
swapf w_temp,w ; restore pre-isr W register contents
retfie ; return from interrupt
main
call ConfigPortB ; RB3 en output RB0:RB2 en input RB4:RB7 en input
call ConfigPortD ; configuration du portd en output
call ConfigPortC ; configuration de RC0 en output
call ConfigPortA ; configuration du porta en input

call configinte

BSF PORTC,RC0 ; alimente le 7 segments
movlw 0X3f
movwf PORTD
boucle
reset_zones
BTFSS PORTC,RC1
goto boucle_reset
movlw 0Xf7
movwf PORTD
boucle_reset
goto boucle
goto $
JUMP_TO_BANK1
BSF STATUS,RP0
BCF STATUS,RP1
RETURN
JUMP_TO_BANK0
BCF STATUS,RP0
BCF STATUS,RP1
RETURN
ConfigPortA
CALL JUMP_TO_BANK1
MOVLW 0X11
movwf TRISA
call JUMP_TO_BANK0
return
ConfigPortB
CALL JUMP_TO_BANK1
movlw B'11111111'
movwf TRISB
CALL JUMP_TO_BANK0
return
ConfigPortD
CALL JUMP_TO_BANK1
MOVLW 0X00
MOVWF TRISD
CALL JUMP_TO_BANK0
return
ConfigPortC
CALL JUMP_TO_BANK1
movlw 0XFE
movwf TRISC
CALL JUMP_TO_BANK0
return
configinte
CALL JUMP_TO_BANK1
movlw 0X98
movwf INTCON
movlw 0X80
movfw OPTION_REG
CALL JUMP_TO_BANK0
return
service_interrupt
movf PORTB,W
BCF INTCON,RBIF
movwf PORTB
BCF INTCON,GIE
TEST1
BTFSS PORTB,RB4
GOTO TEST2
GOTO SHOW1
TEST2
BTFSS PORTB,RB5
GOTO TEST3
GOTO SHOW2
TEST3
BTFSS PORTB,RB6
GOTO TEST4
GOTO SHOW3
TEST4
BTFSS PORTB,RB7
GOTO end_interrupt
GOTO SHOW4
SHOW1
movlw 0X06
movwf PORTD
GOTO end_interrupt
SHOW2
movlw 0X5B
movwf PORTD
GOTO end_interrupt
SHOW3
movlw 0X4F
movwf PORTD
GOTO end_interrupt
SHOW4
movlw 0X66
movwf PORTD
GOTO end_interrupt
end_interrupt
return
service_interrupt_2
BCF INTCON, GIE
BCF INTCON, INTF
movlw 0XF7
movwf PORTD
return
end
Tue Apr 28 2020, 04:21 AM
#4
The code is hard to read.
Please zip it and attach it to your post.
Before you zip, it please add lots of comments to explain how each part works.
Imagine you are explaining each step to someone who has never seen your project before.
This is good practise, because if you come back to this code in a few months
you will have forgotten how it works.
Also please zip and post a circuit diagram, even if it is only a rough sketch.

Get Social

Information

Powered by e107 Forum System

Conversation

scena
Tue May 19 2020, 06:29 PM
Does anyone have microcontroller programming software for STC15F104W (core 8051, 4 k, 128 byte, 6 I/O pin, UART ... DIL8), that works?
Sat May 02 2020, 03:38 PM
Tamu Gurung
Hi I am looking for a assembly language program for a digital decimal counter. Time counts max limit of 2 mins starting from 2.00 mins and ending at 0.00. time is to be displayed on 4 7-segment LED displays. Edsim51 simulator to be used. Thanks
Wed Mar 25 2020, 09:39 AM
Tajammul
Sir kindly send the code file i2c for 8051
ExperimenterUK
Fri Mar 13 2020, 06:36 PM
@ Rohitnani,ABEBE..which project ?
Fri Mar 13 2020, 08:55 AM
ABEBE
how can get hadwere of this project
Rohitnani
Sat Mar 07 2020, 12:11 PM
Sir, Could you please send me the zip file input password....
Wed Feb 26 2020, 11:58 AM
Peter Parker
Is it possible to send multiple messages using only 1 GSM module?
Sat Feb 01 2020, 05:12 AM
Pearl Olin
Hello,
Wed Jan 22 2020, 01:16 PM
MINU CHAUDHARY
I m getting errors while simulation process during interfacing socket output and lcd... Can i get the report of ur project which is same as us.
Tue Jan 14 2020, 02:08 AM
shubham kharade
when i am trying to simulate the program in Proteus 8 professional, I am getting some errors as cannot find module file dhtxx.md can u help me

Downloads

Comments

Davidthils
Thu May 21 2020, 08:44 AM
Jakeror
Wed May 20 2020, 09:28 PM
motorCar
Wed May 20 2020, 03:05 PM
Vordrync
Wed May 20 2020, 07:52 AM
JadenjiT
Wed May 20 2020, 03:15 AM
scena
Tue May 19 2020, 06:08 PM
CodySiz
Tue May 19 2020, 02:22 PM
ClaireSat
Mon May 18 2020, 09:50 PM

Online

Guests: 43, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 01:37 AM

Members: 38211
Newest member: Davidthils
Forum Activity
xrxx Avatar
Posted By xrxx
Thu Apr 30 2020, 06:59 AM
BCD MULTIPLICATIONAssume that you have to 2 BCD nu...
liqian Avatar
Posted By liqian
Tue Apr 28 2020, 05:26 AM
I happened to see your post and I got many useful ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Apr 28 2020, 04:21 AM
The code is hard to read.Please zip it and attach ...
rogermado Avatar
Posted By rogermado
Sun Apr 26 2020, 01:53 AM
@ExperimenterUK, thanks for your reply. You'll fin...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sat Apr 25 2020, 05:42 PM
Some simulators handle displays better than others...
rogermado Avatar
Posted By rogermado
Sat Apr 25 2020, 03:59 PM
Hello everyone, sorry in advance if i'm not in the...
PHANTOM28 Avatar
Posted By PHANTOM28
Fri Feb 28 2020, 10:25 AM
Hi.I hope you all can help me. I am relatively ne...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Feb 21 2020, 05:05 PM
ajay_bhargav Avatar
Posted By ajay_bhargav
Fri Feb 21 2020, 04:45 AM
Yes you can do that.1. Create a channel @Thingspea...
ananyagupta Avatar
Posted By ananyagupta
Thu Feb 20 2020, 03:58 AM
With regards to the particular characters sent to ...