My code size is above 64k so now I need to do code banking. Using the Cygnal IDE I fit my .OBJ files in banks 0, 1, and 2. Don't need bank 3 yet. My question is, after I compile I get a an executable (or byte code, or 8051 machine code) file that I can download. But my bootloader uses the HEX file format. Since my executable is "banked" now, can I still simply run the OH51 program over my executable binary to create a single HEX file? Or MUST I use the OC51 program on the binary to create the banked object files, and then use OH51 on each bank object file to create multiple HEX files? And if this is necessary, how can I combine the HEX files so that I only have a single HEX file. My bootloader only works with a single HEX file. If the files *are* combined into a single HEX file, how will my bootloader know which bank to write the bytes? Or would it be easier to modify my bootloader to accept 4 HEX files and specify which bank they go into?
Well I couldn't get that way to work. So now I am uploading 3 separate HEX files to my bootloader. The bootloader will expect them sequentially so will switch banks when it starts to receive each new one. However, I do not think it is sticking the code in the appropriate bank. It all downloads fine and the bootloader runs the app. But strange things occur and the app does not run correctly. I want to make sure I am switching banks in software correctly. According to page 175 of my Cygnal c8051F12x.pdf it says set the COBANK bits (PSBANK.5-4) for the appropriate bank. The bank is an unsigned char variable and I am setting it like this in my bootloader: // clear and select bank (COBANK bits 4,5) PSBANK = (PSBANK & ~0x30) | (bank << 4); Is this right? If so, any advice on what else I could check? When I download the 3 separate HEX files using the Cygnal IDE, the app runs correctly. So I believe the problem is in my bootloader. The bootloader worked great, until I started trying to write bytes to separate banks.