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.

LCD+keypad interface -> menu structure. Concepts sought. Assembly. PIC.

Status
Not open for further replies.
Hi Astronomer',

Sorry to hear you're having trouble.

I was referring to implementing the PutString in-line string sub-system on 18F' devices. Basically you save memory for each macro call because the PutString subroutine can pull the string table address from the stack and then return to the calling program one instruction past the in-line string table. Another advantage on the 18F' is that you use the DB storage directive which stores 2 characters in each 16-bit memory word.

Here are the components;

Mike

Code:
;
;  PutStr macro
;
PutStr  macro   str             ; print in-line string macro
        call    PutString       ;
        db      str,0           ; null terminated in-line string
        end
Code:
;******************************************************************
;
;  PutString - print in-line string via Stack and TBLPTR
;
;  string must be terminated with a 00 byte and does not need
;  to be word aligned
;
PutString
        movff   TOSL,TBLPTRL    ; copy return address into TBLPTR
        movff   TOSH,TBLPTRH    ;
        clrf    TBLPTRU         ; assume PIC with < 64-KB
PutNext
        tblrd   *+              ; get in-line string character
        movf    TABLAT,W        ; last character (00)?
        bz      PutExit         ; yes, exit, else
        rcall   Put232          ; print character
        bra     PutNext         ; and do another
PutExit
        btfsc   TBLPTRL,0       ; odd address?
        tblrd   *+              ; yes, make it even (fix PC)
        movf    TBLPTRH,W       ; setup new return address
        movwf   TOSH            ;
        movf    TBLPTRL,W       ;
        movwf   TOSL            ;
        return                  ;
 
Last edited:
The menu system - written in assembly - turned out to be by far the largest part of the code.
They can get pretty big, and ugly and confusing. In assembly it can get quite "spaghetti-ish" too. I know from harsh experience.

Sadly Hitech's C compiler for 16F devices simply kills my MPLAB (v8.10), so I was thinking of investigating the 18Fs (i have a couple of 18F4550) - presumably using microchip's C18 compiler.
Have a look at SourceBoost's BoostC. Good compiler. The demo works on almost all PICs. It is code size and RAM limited, but allows enough to get some decent work done before you hit the limits. And the best part is that a full license is only around $75 (Microchip's C18 is around $500). That $75 gets you both 16F (and some 12F) and 18F compilers.

So, how does one achieve a 'smaller, tighter, cleaner' menu system on the 18F compared to the 16F? Just by using C, or does the 18F have something particularly special?
18F's have some good instructions that can save some lines of assembly code (they're much less RISC than the 16F's), but large menus can still get large and confusing.

C code will almost always be quicker to implement and clearer to read, especially after you've been away from the source code for a while.
 
Last edited:
I will also endorse Sourceboost BoostC for 12F' and 16F' devices. For 18F' devices I use Microchip's MCC18 free/student edition.

Mike
 
I just want to thank you both. I'm learning C now - ten years in the coming - using C18 and Wilmshurst's book. A strategy is starting to take shape, although this is going to take some time.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top