User Tools

Site Tools


using_pic18f4620

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
using_pic18f4620 [2006/07/09 08:37]
stryd_one All it takes is one typo, and your code is stuffed ;)
using_pic18f4620 [2011/11/18 12:14] (current)
lpdunwell removed spam
Line 1: Line 1:
 +====== Using the PIC18F4620 or PIC18F4520 ======
  
- +FIXME This is really outdated!!!
-====== Using the PIC18F4620 or PIC18F4520 ====== +
-==== Note that there are some missing steps in this documentation ==== +
-I am making corrections. and will post them shortly.\\ +
-\\+
  
 Historically,​ MIOS was developed to run on a core module stuffed with a PIC18F452. Recently, the PIC18F4620 has become available. It is near code-compatible with the 452, but features a significant increase in RAM/​EEPROM/​Codespace. See [[mios_pic18f4620|the PIC18F4620 page]] for details. Historically,​ MIOS was developed to run on a core module stuffed with a PIC18F452. Recently, the PIC18F4620 has become available. It is near code-compatible with the 452, but features a significant increase in RAM/​EEPROM/​Codespace. See [[mios_pic18f4620|the PIC18F4620 page]] for details.
Line 14: Line 11:
 ====== OS Layers ====== ====== OS Layers ======
  
-MIOS v1.9b or above is required. You will need to download the MIOS source from [[http://​www.ucapps.de/​mios_download.html|The uCApps.de Download Page]] or [[http://​www.ucapps.de/​mios/​mios_v1_9b_src.zip|Directly]]. I recommend checking the first link for the latest version, as the '4620 is current in beta.\\+MIOS v1.9b or above is required. You will need to download the MIOS source from   ​[[http://​www.ucapps.de/​mios_download.html|The uCApps.de Download Page]] or [[http://​www.ucapps.de/​mios/​mios_v1_9c_src.zip|Directly]]. I recommend checking the first link for the latest version, as the '4620 is current in beta.\\
 \\ \\
 The Bootloader and MIOS recompile steps which follow should not be necessary for most cases of '4620 use, as these components are now available precompiled and packaged in a zip file [[http://​www.ucapps.de/​mios/​mios_update_v1_9b.zip|hosted on uCApps.de]] Instructions follow for reference only, or for '4520 use.\\ The Bootloader and MIOS recompile steps which follow should not be necessary for most cases of '4620 use, as these components are now available precompiled and packaged in a zip file [[http://​www.ucapps.de/​mios/​mios_update_v1_9b.zip|hosted on uCApps.de]] Instructions follow for reference only, or for '4520 use.\\
Line 48: Line 45:
 \\ \\
   * Compile the project FIXME wiki link   * Compile the project FIXME wiki link
 +  * also see: [[Compiling the MIDIbox source on Linux]] - using GPASM (Linux, Mac) instead of MPLAB (Windows)
 \\ \\
   * Upload the hex file with MIOS Studio FIXME wiki link   * Upload the hex file with MIOS Studio FIXME wiki link
Line 96: Line 94:
  
 If your application is C-based, then the following steps are required. Some are optional recommendations,​ as noted. If your application is C-based, then the following steps are required. Some are optional recommendations,​ as noted.
 +
 +== Note on compile errors ==
 +
 +When compiling your C-based application,​ you may see an error such as this:
 +
 +  Linking project
 +  warning: processor mismatch in "​_output\mios_wrapper.o"​
 +
 +This error is caused by SDCC compiling the application for the PIC18F452. Fortunately,​ the code is compatible between the two chips, so this error can be ignored. Thanks to bill, for having the guts to put the app on his PIC, and confirm that this was the case ;)
  
 ==== Header and Library ==== ==== Header and Library ====
Line 157: Line 164:
 goto MIOS_HLP_Dec2BCD goto MIOS_HLP_Dec2BCD
 </​code>​ </​code>​
 +
  
  
  
 ==== Linker Script ==== ==== Linker Script ====
 +
  
 Modifications should be made to the linker script in order to take advantage of the additional capabilities of the 4620/​4520. ​ Modifications should be made to the linker script in order to take advantage of the additional capabilities of the 4620/​4520. ​
Line 175: Line 184:
 To To
   CODEPAGE ​  ​NAME=page ​      ​START=0x3000 ​        ​END=0xFFFF   CODEPAGE ​  ​NAME=page ​      ​START=0x3000 ​        ​END=0xFFFF
 +
 +
 +If you are using a GLCD with your PIC18F4620 the GLCD Font of the MIOS will be overwritten by this change though, as it lies in the range of 0x7C00-0x7FFF. There are __two__ approaches to prevent this (also see forum thread http://​www.midibox.org/​forum/​index.php?​topic=7540.0):​
 +
 +  * To leave out the Font space in the PIC´s code memory, change
 +
 +   ​CODEPAGE ​  ​NAME=page ​      ​START=0x3000 ​        ​END=0x7FFF
 +To
 +   ​CODEPAGE ​  ​NAME=page0 ​     START=0x3000 ​        ​END=0x7BFF
 +   ​CODEPAGE ​  ​NAME=page1 ​     START=0x8000 ​        ​END=0xFFFF
 +
 +__**or**__ try this solution from TK:
 +
 +    * copy the mios_glcd_font.inc file from the MIOS release into your application directory, rename it to mios_glcd_font.asm
 +    * add following code to the file header:
 +
 +        LIST P=PIC18F4620,​ R=DEC
 +  DEFAULT_FONT code
 +  FONT_ENTRY MACRO width, height, x0, char_offset
 +        dw      ((height) << 8) | (width), ((char_offset) << 8) | (x0)
 +        ENDM
 +
 +
 +    * change the "​org"​ (start address) from 0x7cfc to 0xfcfc
 +    * add a "​END"​ at the file footer
 +    * add the new .asm file to the MAKEFILE.SPEC (behind the MK_SET_OBJ statement)
 +    * change the font pointer within the Init() routine:
 +
 +  void Init(void)
 +  {
 +  MIOS_GLCD_FontInit(0xfcfc);​
 +  }
 +
 +    * if you are working under MacOS or Linux, type "perl tools/​mkmk.pl MAKEFILE.SPEC;​ make", under DOS just type "​make"​
 +
 +The first approach has the advantage, that it isn't required to upload the font again and again with each program update.
 +The second approach that new fonts can be inserted into the project in a similar way.
 +Please see the forum article mentioned above on instructions how to use labels in combination with fonts.
  
 === Add Databanks === === Add Databanks ===
Line 208: Line 255:
 \\ \\
 ==Extended Bank Capacity== ==Extended Bank Capacity==
 +
 +__**Be Careful doing this!!**__
 +This can do weird things like make variables always = 0 where the memory that variable is stored in, crosses boundaries of 256b blocks. Do not make banks any larger than required, and try to let them begin at round numbers (100, 200, 300,...). This still might not even work. - stryd_one
 +
  
 The above change will enable SDCC to allocate the variables in your application to any of the specified banks above. The very observant among you may have noticed that these banks are 256 bits each.... So what happens if you want to use a variable which is greater than 256 bits in size, such as a large array, or string of characters? For this, you will need to create a bank of extended size, and you will need to direct your application to use that bank to store your large variable. The above change will enable SDCC to allocate the variables in your application to any of the specified banks above. The very observant among you may have noticed that these banks are 256 bits each.... So what happens if you want to use a variable which is greater than 256 bits in size, such as a large array, or string of characters? For this, you will need to create a bank of extended size, and you will need to direct your application to use that bank to store your large variable.
Line 253: Line 304:
 \\ \\
  
-Or of course you could make the whole lot into one bank if you wanted to: +Or of course you could make the whole lot into one bank if you wanted to. This is NOT recommended though!
 <​code>​ <​code>​
 DATABANK ​  ​NAME=miosram_u ​ START=0x380 ​         END=0x5FF  ​  ​PROTECTED DATABANK ​  ​NAME=miosram_u ​ START=0x380 ​         END=0x5FF  ​  ​PROTECTED
Line 286: Line 337:
  
 You may create as many or as few sections as you require for your application. ​ You may create as many or as few sections as you require for your application. ​
 +
 +
  
 ==== Application Code ==== ==== Application Code ====
Line 297: Line 350:
 <​code>​ <​code>​
 #pragma udata b512 MIDI_Table ​      // This means "store a variable named '​MIDI_Table'​ in the SECTION named '​b512'​ #pragma udata b512 MIDI_Table ​      // This means "store a variable named '​MIDI_Table'​ in the SECTION named '​b512'​
-unsigned ​int MIDI_Table[512]; ​      // Declare the array named '​MIDI_Table',​ and now it will be stored in '​b512'​+unsigned ​char MIDI_Table[512]; ​      // Declare the array named '​MIDI_Table',​ and now it will be stored in '​b512'​
 </​code>​ </​code>​
  
-Still reading;)+**It is recommended to avoid this wherever possible.** Allow the compiler to allocate the memory wherever possible! 
 + 
 +Check [[http://​www.midibox.org/​forum/​index.php?topic=8934.0|An answer to the extended databanks problem]] for more info!!!!!!!!!! 
 + 
 +\\ 
 +  * Compile the project FIXME wiki link 
 +\\ 
 +  * Upload the hex file with MIOS Studio FIXME wiki link 
 +\\ 
 +\\ 
 +\\
  
 +Still reading? Shouldn'​t you be writing code right now? ;)
using_pic18f4620.1152434278.txt.gz · Last modified: 2006/10/15 09:35 (external edit)