[Flashforth-devel] pic18f66k22
Brought to you by:
oh2aun
From: <zd...@al...> - 2016-02-22 17:20:50
|
Hi, everyone, It was easy to import files to MPLAB, and I expected that after my hardware was soldered only 1 download to PIC will be enough to start working in FlashForth. Well, I started programming in Forth in 1984 and I have 20 years of experience with PICs and shouldn't describe myself as an begginer, but still I needed almost a week to make FF work. I'm afraid most people could just give up. That's why I would like to discuss my problems here and make whole package more user frendly. MPLAB project has many files included, some of them non existent. Obviously, I had to include p18f66k22.cfg, but it wasn't clear that I have to exclude most of files because baud rate calculation didn't work correct. Apparently it was calculating for 48MHz although in p18f66k22.cfg it was correct 64MHz. Finally, I got some "FlashForth" response on my terminal but it was impossible to work as it didn't accept command line and kept restarting every couple of seconds. After one day with in-circuit emulator I wasn't smarter as it didn't behave the same way every time I tried to trace it, so the next day I conected a beeper and turned it on from different points in code to see how far it gets. In the end of the second day it was obvious it is freezing on attempt to write into EEPROM. No wonder, as EEIF flag is not in PIR2, but PIR6 on 18F66K22. ECSTORE1: bcf EECON1, EEPGD, A bcf EECON1, CFGS, A bcf PIR2, EEIF, A bsf EECON1, WREN, A bcf INTCON, GIE, A movlw h'55' movwf EECON2, A movlw h'aa' movwf EECON2, A bsf EECON1, WR, A bsf INTCON, GIE, A ECSTORE2: btfss PIR2, EEIF, A bra ECSTORE2 bcf EECON1, WREN, A bcf PIR2, EEIF, A There are 2 conclusions. First, some important pointers have to be written into EEPROM before anything starts to work. Second, nobody ever tried this code on any 65K22, 66K22, 85K22 or 86K22. Now FF started working, but only until first colon definition and then everything fell apart. Few more days of reprogramming, reading code, reprogramming, reading "manual", reprogramming, reading dump, comparing until I found error in p18f66k22.cfg. constant flash_write_inner_loop = d'128' Only 18x7K22 has 128 byte buffer and as a result all attempts to write to flash memory were fatal. As I can see now, Forth works but I'm still confused with words that exist in "Hitchhiker's Guide to FlashForth" but not in FF (forget) or vice versa (iflush). To patch the file i suggest copying this 3 times into FF assembler code: #ifdef PIR6 bcf PIR6, EEIF, A #else bcf PIR2, EEIF, A #endif ... and change d'128' into d'64' in .cfg for 18F65K22, 18F66K22, 18F85K22 & 18F86K22. Has anyone tried to use USART2 instead of USART1? Zdravko |