PIC16F88 05 Simulator |
|
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.
; ---- 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
Please report website problems to Neil