Site Logo Home
 
rOm
Quest
Glossary
 
Random
Page
Search
Site
Lush
Sim
Class
Subject
Images
 
Help
FAQ
Sign
Up
Log
In
A Level     PIC16F88     01 PICkit3     02 MPLAB X     03 Config Bits     04 OSCCON     >05 Simulator<     06 TMR0IF Polling     07 Traffic Lights     08 Stepper Motor     09 TMR0IF Interrupts     0A Data Table     0B Digital I/O     0C ADC Input     0D Multiplex     0E Servo PWM     0F LED Matrix     10 OLED Display    

PIC16F88 05 Simulator


Site for Eduqas/WJEC - Go to the AQA site.

MPLAB-X has its own simulator with quite a steep learning curve but it's worth the effort. It seems to be more fussy about configuration register settings than the real life chip. Occasionally PORTA seems to be incorrectly simulated with some pins failing to set.

This example repeatedly toggles all the PORTA and PORTB pins on and off apart from RA5 which is input only.

Simulating the code while watching the special function registers and user-defined variables can often explain why a program is not working as expected.

Video Guide - 5 Minutes

PIC16F88 Assembly Code Example for the MPLABX Simulator

; ---- EXAMPLE CODE ---- TOGGLE PORTA and PORTB pins in the simulator - Please watch the video.
#include "p16F88.inc"
 __CONFIG _CONFIG1, _FOSC_INTOSCIO & _WDTE_OFF & _PWRTE_OFF & _MCLRE_OFF & _BOREN_OFF & _LVP_OFF & _CPD_OFF & _WRT_OFF & _CCPMX_RB0 & _CP_OFF
 __CONFIG _CONFIG2, _FCMEN_ON & _IESO_ON

RES_VECT  CODE    0x0000            ; processor reset vector
    GOTO    START                   ; go to beginning of program

MAIN_PROG CODE                      ; let linker place main program

START:				    ; INITIALISATION
    bsf	    STATUS,	RP0         ; Select bank 1.
    movlw   b'00000000'		    ; Set all port pins to output / Disable ADC / Set for digital i/o
    movwf   ADCON1		    ; Disble ADC module (Never leave this to chance)
    movwf   ANSEL		    ; Set analog i/o for digital i/o (Never leave this to chance)
    movwf   TRISA		    ; Set porta - RA5 is input only so this bit is ignored
    movwf   TRISB		    ; Set portb
    bcf	    STATUS,	RP0         ; Select bank 0.

MYLOOP:
    ; Toggle all port pins ON (except RA5)
    movlw   0xFF
    movwf   PORTA		    ; RA5 is input only
    movwf   PORTB
    nop
    nop
    
    ; Toggle all port pins OFF (except RA5)
    movlw   0x00
    movwf   PORTA		    ; RA5 is input only
    movwf   PORTB
    GOTO    MYLOOP    

    END

 

 

 

Contact, Copyright, Cookies and Legalities: C Neil Bauers - reviseOmatic V4 - © 2016/17

Hosted at linode.com - London