nmeyer
Joined: 09 Jul 2004 Posts: 70
|
Help Needed-PIC18F8722 and Extended Memory |
Posted: Fri Jan 02, 2009 11:22 am |
|
|
Hi, I have been trying to set up the pic18f8722 with the extended memory to use external flash for program space. I would like the flash in the chip to fill with program code and then flow over into the external flash with what is left. I have read through a lot of posts on this forum and i am not sure if i am understanding the whole picture. I am using the PIC18F8722 development kit from CCS to prototype what i am doing for my design. From other posts on this forum i have gathered that i need to set the fuses to EMCU, create a new device that has the sum of the internal memory and external memory, make a new *.h file that contains this new device. Also, it appears that i need to use the #build and #org functions in my program, but that is where i get confused as to why and how to set them up. I have attached a test program that i want to load into the external flash. When i do this on my board, the board does nothing or i get errors that the verify has failed because locations 0x20000 and above have 00 instead of valid information. Does my program logic make sense? Am i missing something in the set up?
Code: |
#include <18F8722EX.h>
#device adc=10
#FUSES WDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES HS //High speed Osc (> 4mhz)
#FUSES NOPROTECT //Code not protected from reading
//#FUSES NOBROWNOUT //No brownout reset
#FUSES BROWNOUT //BROWN OUT ON
#FUSES BORV27 //RESET VOLTAGE AT 2.7V
//#FUSES BORV42 //RESET VOLTAGE AT 4.2V
//#FUSES BORV25 //Brownout reset at 2.5V
#FUSES NOPUT //No Power Up Timer
#FUSES NOCPD //No EE protection
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES FCMEN //Fail-safe clock monitor enabled
//#FUSES PBADEN //PORTB pins are configured as analog input channels on RESET
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES NOCPB //No Boot Block code protection
//#FUSES LPT1OSC //Timer1 configured for low-power operation
#FUSES MCLR //Master Clear pin enabled
#FUSES NOXINST //Extended set extension and Indexed Addressing mode enabled
#FUSES EMCU
#FUSES ABW20
#FUSES BW16
#include <stdio.h>
#include <math.h>
#include "Z:\Projects\132-Rawson\07-012 AccurateII\Code\Extended Memory\at29c1024.c"
#include "Z:\Projects\132-Rawson\07-012 AccurateII\Code\Extended Memory\bootloader.h"
#include <stdlib.h>
#use delay(clock=20000000,RESTART_WDT)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,RESTART_WDT,ERRORS,stream=SP1)
//#build (memory=0x20000:0x3FFFF)
int count,count_read;
#org 0x20000
void main()
{
//init_ext_flash_memory();
count=0;
while(true)
{
//count_read=read_ext_flash_memory(0x50);
fprintf(SP1,"%c",count_read);
delay_ms(500);
count++;
//write_ext_flash_memory(0x50,count);
}
}
| [/code] |
|