|
|
View previous topic :: View next topic |
Author |
Message |
pasini
Joined: 12 Dec 2005 Posts: 50 Location: Curitiba - Brazil
|
PIC18F8680/External Flash Memory doubt |
Posted: Mon Feb 06, 2006 1:24 pm |
|
|
I have a PIC18F8680, running at 20MHz/5V, connected to an external AM29F800B Flash memory. I have 2 74HC373 between memory and MCU, in a 8051-like way.
The code runs for others tasks but I see no memory signals on the scope.
MPLAB 7.3 PCB/PCM/PCH 4.241
Does anybody has a sample routine I can see or any suggestions ?
Thanks in advance.
Pasini
My code is:
Code: | #include "18f8680.h"
#device *=16 ADC=10
#fuses HS,NOWDT,NOPUT,NOPROTECT,NOBROWNOUT,NOLVP,NOCPD,NOWRT,EMCU,WAIT
#use delay(clock=20000000)
#use FAST_IO (C)
#case
void WriteExtFlash(void)
{
int32 i;
int8 value;
value= 0xAB;
for(i=0;i<=9;i++)
{ value = i;
write_external_memory(i, &value, 1);
delay_ms(7);
}
}
void ReadExtFlash(void)
{
char buffer[10];
read_external_memory(0, buffer, 10);
delay_ms(1);
}
void TesteMemoria(void)
{
char buffer[100];
while(1)
{ DesligaMem();
LigaMem();
WriteExtFlash();
ReadExtFlash();
}
}
void main(void)
{
// setup PWM
setup_ccp1 (CCP_OFF); // disable PWM hardware
setup_ccp2 (CCP_OFF); // disable PWM hardware
// setup ADC
setup_adc_ports(AN0_TO_AN1|VSS_VDD);
setup_adc(ADC_CLOCK_DIV_32);
// setup counters
setup_counters(RTCC_INTERNAL,RTCC_DIV_2);
// setup external memory
LigaMem(); // is equal to output_high(RESET_MEM)
setup_external_memory(EXTMEM_WORD_WRITE|EXTMEM_WAIT_0);
// setup interrupts
enable_interrupts(INT_TIMER0);
enable_interrupts(GLOBAL);
set_tris_a(0b00010011);
set_tris_g(0b00000000);
set_tris_c(0b11000011);
set_tris_f(0b00000000);
set_tris_j(0b00000000);
// definis iniciais
DesligaBuzzer();
LigaBckLight();
LigaContraste();
LigaMCU();
LigaMem();
TesteMemoria();
} |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Feb 07, 2006 2:11 am |
|
|
The data sheet for the 18F8680 has a chart on page 55 (in the Acrobat
reader) which shows that in Extended Microcontroller mode, the external
memory starts at address 0x10000.
If you look in the CCS driver file AT29C1024.C, they add the offset
within the external memory chip to the base address of the external
memory, in order to create the full correct address. You need to do
this too. Example:
Code: |
#define EXT_MEM_BASE_ADDR 0x10000
write_external_memory(EXT_MEM_BASE_ADDR + i, &value, 1); |
And also for the read:
Code: | read_external_memory(EXT_MEM_BASE_ADDR, buffer, 10); |
I haven't used external memory before, so I don't know for sure
if this is the complete answer to get it running, but it will certainly help. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|