Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC 16F88 header generator using Just BASIC.

Status
Not open for further replies.
I'm thinking about writing a header generator for the 16F88 and my Firefly User guide using the free Just BASIC 1.01
It will generate a header based on config choices for MPASM. It's designed for beginners and will be fully documented in the guide.

Is there anything like that now? free...
 
What, you mean just to create the __CONFIG line?, and presumably the INC line as well.

Obviously the only 'slightly' tricky part is the __CONFIG line, I always use WinPicProg, select the options I want, and use the HEX value it gives me :D
 
Yes, that's the idea. But generates the .asm file for MPLAB. With a few more options specific to the Firefly. Ie comparators off / on, internal RC osc speed. A few lines of startup code... the include files etc...
Code:
        include "p16f88.inc"
         errorlevel -302            ;suppress warning

         __CONFIG _CONFIG1, 0x2F30
         __CONFIG _CONFIG2, 0x3FFC

mov      macro    x,y                ;Intel style mov <register>, <literal>
         movlw    y                  ;y = literal
         banksel  x                  ;make sure it's in the right bank
         movwf    x                  ;register = W
         endm                        ;warning exits with x bank selected
         org      0x000
         

Init     mov      OSCCON, b'01100010' ;4MHz internal RC clock
         mov      CMCON, 0x7          ;turn off comparators
;insert your code here
         
         end
 
Last edited:
Wouldn't be a bad thing to have. Of course, it would be nice if it supported more than just one PIC, but that probably involves a lot of manual labor, grabbing datasheets and setting up all the config options for every PIC...

I find myself doing exactly what nigel said... Opening up a programming app like ICProg or WinPICProg or something, setting up the config, and copying the HEX values from there.

If I were to do it, I'd probably start in something a little more mainstream like VB or C#, but that's just personal preference. I don't know much about the capabilities of this "just BASIC", but in .NET languages I can envision a system whereby the different config options of all the PICs could be specified in a .ini or XML file or something and would be imported at runtime, making it easy for an end user to specify the config options of a new PIC to add support for it, using a simple text editor... and thus taking the load off the original programmer for adding device support... It also wouldn't be too hard to offer different options of code output - ie - generate an ASM header, or just generate the config words alone, or make it easy to add custom formats for different compilers out there.

Though I'm sure all that would be quite outside the scope of your goals, if you're just looking to make a support app for your F88 demo board(s) ;)
 
It's alot of work for one fellow :). I'm working on the Firefly user guide, Just BASIC is much smaller than visual basic and very straight forward. Now I'll post the source code as its developed. As for code fuses MPLAB has the same drop down config thing. But I'd like to simplify it and remove the fuses that don't apply to the Firefly.

Simple keeps the beginner interested. Most of us when we began couldn't wait to light that LED at any cost...
 
Microchip supply templates in the C:\Program Files\Microchip\MPASM Suite\Template\Code folder.

Here is whats in the 88 file (f88temp.asm)
Code:
	list      p=16f88           ; list directive to define processor
	#include <p16F88.inc>        ; processor specific variable definitions

	errorlevel  -302              ; suppress message 302 from list file

	__CONFIG    _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_IO
	__CONFIG    _CONFIG2, _IESO_OFF & _FCMEN_OFF

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




;***** VARIABLE DEFINITIONS
w_temp        EQU     0x71        ; variable used for context saving 
status_temp   EQU     0x72        ; variable used for context saving
pclath_temp   EQU     0x73	  ; variable used for context saving





;**********************************************************************
	ORG     0x000             ; processor reset vector
	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

; isr code can go here or be located as a call subroutine elsewhere


	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

; remaining code goes here



; initialize eeprom locations

	ORG	0x2100
	DE	0x00, 0x01, 0x02, 0x03


	END                       ; directive 'end of program'
 
Status
Not open for further replies.

Latest threads

Back
Top