Re: [Flashforth-devel] empty for PIC24 family
Brought to you by:
oh2aun
From: Peter J. <pe...@me...> - 2014-04-29 07:25:44
|
Mike, You're most welcome to the tutorials. Your FF program has been a pleasure to work with. How did your preparations for introducing FF to Finnish children go? I see your notes to Pete Zawasky, so I'll try to experiment with the PIC24 again, once I have the tutorial sections complete for the PIC18. Checking that the eeprom is erased when first flashing the chip might be a good start. I've used your bit0: and bit1: words in the LCD demo that I built today. (See below.) They seem to work nicely (on a PIC18F46K22). Cheers, Peter J. \ Exercise LCD on PICDEM2+ board. \ Remember to load bit.txt before this file. -xlcd marker -xlcd $ff80 constant porta $ff89 constant lata $ff92 constant trisa $ff83 constant portd $ff8c constant latd $ff95 constant trisd \ The LCD is operated in nibble mode. \ RA1 = Enable (E) pin \ RA2 = Read/Write (RW) pin \ RA3 = Register Select (RS) pin \ RD0 = DB4 on LCD \ RD1 = DB5 \ RD2 = DB6 \ RD3 = DB7 portd constant dataport lata #1 bit0: Elo lata #1 bit1: Ehi lata #2 bit0: RWlo lata #2 bit1: RWhi lata #3 bit0: RSlo lata #3 bit1: RShi : data-port-in ( -- ) trisd c@ $0f or trisd c! ; : data-port-out ( -- ) trisd c@ $f0 and trisd c! ; : put-nibble ( c -- ) \ Make lower 4 bits of c appear on data port pins. $0f and dataport c@ $f0 and or dataport c! ; : short-delay ( -- ) 18 for r@ drop next ; : Estrobe ( -- ) Ehi short-delay Elo ; : lcd-getc ( -- c ) \ Read the LCD register in two nibbles. \ Remember to select the register line before calling this word. data-port-in RWhi short-delay Ehi short-delay dataport c@ #4 lshift Elo short-delay \ high nibble Ehi short-delay dataport c@ Elo short-delay \ low nibble or \ assemble full byte and leave it on the stack RWlo short-delay ; : lcd-ready? ( -- f ) \ Read the command register and check busy bit. RSlo short-delay lcd-getc $80 and 0= ; : wait-for-lcd ( -- ) begin lcd-ready? cwd until ; : lcd-putc ( c -- ) \ Write the LCD register in two nibbles. \ Remember to select the register line before calling this word. dup $f0 and #4 rshift \ high nibble left on top of stack data-port-out RWlo short-delay put-nibble short-delay Estrobe short-delay $0f and \ low nibble now left on top of stack put-nibble short-delay Estrobe short-delay data-port-in ; : lcd-clear ( -- ) wait-for-lcd RSlo short-delay %00000001 lcd-putc ; : lcd-home ( -- ) wait-for-lcd RSlo short-delay %00000010 lcd-putc ; : lcd-goto ( c -- ) \ Set the specified 7-bit data memory address. wait-for-lcd RSlo short-delay $80 or \ sets the highest bit for the command lcd-putc ; : lcd-init ( -- ) data-port-in Elo RWlo RSlo %00001110 trisa mclr \ RS, RW and E as output 30 ms \ power-on delay %0010 put-nibble Estrobe 5 ms %0010 put-nibble Estrobe 1 ms %0010 put-nibble Estrobe 1 ms data-port-in \ Set LCD for 4-bit interface, 2 display lines 5x7 font. wait-for-lcd %00101000 lcd-putc 5 ms \ Increment cursor after each byte, don't shift display. wait-for-lcd %00000110 lcd-putc 5 ms \ Enable cursor and display, no blink. wait-for-lcd %00001110 lcd-putc 5 ms lcd-clear 5 ms wait-for-lcd ; : lcd-emit ( c -- ) \ Write the byte into data memory. wait-for-lcd RShi short-delay lcd-putc ; : lcd-type ( c-addr n -- ) \ send string for c@+ lcd-emit next drop ; : main ." Begin..." lcd-init cr ." lcd-init done." s" Hello from" lcd-type $40 lcd-goto s" FlashForth 5.0" lcd-type cr ." exercise done." ; On 29/04/14 05:04, Mikael Nordman wrote: > Hi Peter, > I have been meaning to thank you for tutorials. > > Thank you ! > > I have not run the PIC24 code for a while on a chip with eeprom. > Probably the empty values are wrong somehow. > This could be related to some compile time configuration issue. > I cannot check it right now. > > I don't remember why bit parameters between PIC24 and PIC18 are reversed. > Pure happenstance and sloppy thinking from my part... > > You could also test the new BIT0: and BIT1: words while you are at it. > These are the same on all three architectures. > The speed when inlined should be the same as for pure assembly. > > BR Mike > > On 04/28/2014 03:47 PM, Peter Jacobs wrote: >> Mike, >> I'm having a bit of fun updating the tutorials and extending them (a >> little) to the other architectures to which you've ported FF. >> >> A small problem that I'm having tonight is that "empty" does not >> seem to reset the dictionary back to its original state of the >> PIC24FV16KM202. If I put in a marker, I can take the dictionary back to >> the state before that marker, however, I forgot to do that before >> defining a few words and now I don't seem to be able to remove those >> words (short of reprogramming the chip). >> >> Also, for the assembler words bset, and bclr, the order of bit and >> register-address arguments seem to be the reverse of the PIC18 family. >> Why is that? (Just asking out of curiosity and, since I know almost >> nothing about the assembly language of these machines, I don't mind >> being told to read the docs.) >> >> Regards, >> Peter J. >> >> -speed-test >> marker -speed-test >> \ For the PIC24FV16KM202, waggle RB15 as quickly as we can, >> \ in both high- and low-level code. >> >> $02c8 constant trisb >> $02ca constant portb >> $02cc constant latb >> $02ce constant odcb >> >> 1 #15 lshift constant bit15 >> >> : initRB15 >> bit15 trisb mclr \ RB15 as output >> bit15 latb mclr \ initially known state >> ; >> >> \ high-level bit fiddling, presumably slow >> : blink-forth ( -- ) >> initRB15 >> begin >> bit15 latb ! 0 latb ! \ one cycle, on and off >> bit15 latb ! 0 latb ! >> bit15 latb ! 0 latb ! >> bit15 latb ! 0 latb ! >> cwd \ We have to kick the watch dog ourselves. >> again >> ; >> >> \ low-level bit fiddling, via assembler >> : blink-asm ( -- ) >> initRB15 >> [ >> begin, >> #15 latb bset, #15 latb bclr, \ one cycle, on and off >> #15 latb bset, #15 latb bclr, >> #15 latb bset, #15 latb bclr, >> #15 latb bset, #15 latb bclr, >> ] cwd [ \ kick the watch dog >> again, >> ] >> ; >> >> >> >> ------------------------------------------------------------------------------ >> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE >> Instantly run your Selenium tests across 300+ browser/OS combos. Get >> unparalleled scalability from the best Selenium testing platform available. >> Simple to use. Nothing to install. Get started now for free." >> http://p.sf.net/sfu/SauceLabs >> _______________________________________________ >> Flashforth-devel mailing list >> Fla...@li... >> https://lists.sourceforge.net/lists/listinfo/flashforth-devel >> > > ------------------------------------------------------------------------------ > "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE > Instantly run your Selenium tests across 300+ browser/OS combos. Get > unparalleled scalability from the best Selenium testing platform available. > Simple to use. Nothing to install. Get started now for free." > http://p.sf.net/sfu/SauceLabs > _______________________________________________ > Flashforth-devel mailing list > Fla...@li... > https://lists.sourceforge.net/lists/listinfo/flashforth-devel |