![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
pasini
Joined: 12 Dec 2005 Posts: 50 Location: Curitiba - Brazil
|
PIC18F8680 / external memory |
Posted: Thu Mar 16, 2006 6:10 am |
|
|
Hi all,
Does anyone know if PIC18F8680 controls pin J5 (CE = chip enable) while accessing external memory or I have to control it ?
CCS3.241 MPLAB 7.31
I´ve done everything to make the interface work but the flash memory does not responde properly.
CE tries to be high but just a spurious pulse appears.
A piece of my code is as follows.
Thanks in advance
Pasini
Code: |
#include "18f8680.h"
#device *=16 ADC=10
#fuses HS,NOWDT,NOPUT,NOPROTECT,BROWNOUT,NOLVP,NOCPD,NOWRT,EMCU,NOWAIT
#use delay(clock=20000000)
#case
#define BASE 0x010000
int16 add;
int16 val;
void main(void)
{
int16 c=0;
setup_ccp1 (CCP_OFF); // disable PWM hardware
setup_ccp2 (CCP_OFF); // disable PWM hardware
setup_adc_ports(AN0_TO_AN1|VSS_VDD);
setup_adc(ADC_CLOCK_DIV_32);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_4);
setup_timer_2(T2_DIV_BY_16,150,3);
setup_external_memory(EXTMEM_DISABLE|EXTMEM_WORD_WRITE|EXTMEM_WAIT_0);
set_tris_a(0b00010011);
set_tris_g(0b00000101);
set_tris_c(0b11000011);
set_tris_f(0b00000000);
set_tris_j(0b00000000);
output_high(PIN_A3);
// chip erase
write_external_memory(0x0555,0x00AA,2);
delay_ms(300);
write_external_memory(0x02AA,0x0055,2);
delay_ms(300);
write_external_memory(0x0555,0x0080,2);
delay_ms(300);
write_external_memory(0x0555,0x00AA,2);
delay_ms(300);
write_external_memory(0x02AA,0x0055,2);
delay_ms(300);
write_external_memory(0x0555,0x0010,2);
delay_ms(300);
delay_ms(500);
read_external_memory(add+BASE, &val, 2);
add = 0;
while(1)
{ val = 0;
write_external_memory(0x0555,0x00AA,2);
write_external_memory(0x02AA,0x0055,2);
write_external_memory(0x0555,0x00A0,2);
write_external_memory(add+BASE, &val, 2);
add++;
}
} |
|
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Thu Mar 16, 2006 4:14 pm |
|
|
I think you are talking to the wrong addresses...
The address value, is a 32bit number, not a 16bit value. If you were running with the external memory starting at address 0 (in microprocessor mode), then it would begin at this point. However in extended microcontroller mode, the address range for the external memory, begins at 0x0c000.
You also probably don't want the memory disabled (though the code should override this), unless you are using the pins for other functions.
So try:
setup_external_memory (EXTMEM_WORD_WRITE|EXTMEM_WAIT_0);
and
write_external_memory(0x0C555,0x00AA,2);
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|