|
|
View previous topic :: View next topic |
Author |
Message |
leekp8
Joined: 25 Sep 2006 Posts: 6 Location: Malaysia
|
Flash program memory not working |
Posted: Mon Sep 25, 2006 11:12 am |
|
|
Hi,
Can anybody help to look at he following codes as
after program I was not able to read out the correct
codes. I'm not sure if write or read problem.
This is checked in the ICD2 debugger environment.
#include <18F6527.h>
#device *=16 ADC=8 //16bit pointer, 8-bit ADC
//#fuses HS,NOWDT,PROTECT,NOPUT,NOBROWNOUT //,NOLVP //High Speed, No WDT, Code PROTECT, No Brown Out
#use delay(clock=20000000)
//#fuses HS //, WDT128
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, STREAM=RS485)
#use rs232(baud=9600, xmit=PIN_G1, rcv=PIN_G2, STREAM=UART)
int8 i, j, k, x;
int32 ProgramStartAddress;
int16 const TK[] = {0x1234, 0x2345, 0x3456, 0x4567,
0x1234, 0x2345, 0x3456, 0x4567,
0x1234, 0x2345, 0x3456, 0x4567,
0x1234, 0x2345, 0x3456, 0x4567,
0x1234, 0x2345, 0x3456, 0x4567,
0x1234, 0x2345, 0x3456, 0x4567,
0x1234, 0x2345, 0x3456, 0x4567,
0x1234, 0x2345, 0x3456, 0x4567};
#define Buffer_MAX 32
int16 Buffer[Buffer_MAX];
void FlashRWTest()
{
for (i=0; i<32; i++) {
Buffer[i] = 0;
}
ProgramStartAddress = 0x5000;
erase_program_eeprom(ProgramStartAddress);
write_program_memory(ProgramStartAddress, TK, 64);
read_program_memory(ProgramStartAddress, Buffer, 64);
while (1);
}
#ORG 0x01000,0x1fff
void main()
{
FlashRWTest();
} |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Sep 25, 2006 12:28 pm |
|
|
Quote: | int16 const TK[] = {
0x1234, 0x2345, 0x3456, 0x4567,
0x1234, 0x2345, 0x3456, 0x4567,
0x1234, 0x2345, 0x3456, 0x4567, |
I don't think that the write function can accept a constant array.
This is what I'm seeing, from looking at the .LST file.
Try removing the 'const' keyword and see if it starts working.
Also, your #fuses and pre-processor statements need some
improvement. You don't need to specify 16-bit pointers.
PCH automatically uses them. That directive is for the PCM compiler.
You should also add the ERRORS directive to your hardware UART
declarations. Try this:
Code: |
#include <18F6527.h>
#fuses HS,NOWDT,PROTECT,NOPUT,NOBROWNOUT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS, STREAM=RS485)
#use rs232(baud=9600, xmit=PIN_G1, rcv=PIN_G2, ERRORS, STREAM=UART)
|
|
|
|
leekp8
Joined: 25 Sep 2006 Posts: 6 Location: Malaysia
|
Flash program memory not working - 2 |
Posted: Mon Sep 25, 2006 8:15 pm |
|
|
Hi,
After removing const, it works.
However, with
#fuses HS,NOWDT,PROTECT,NOPUT,NOBROWNOUT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS, STREAM=RS485)
#use rs232(baud=9600, xmit=PIN_G1, rcv=PIN_G2, ERRORS, STREAM=UART)
it gave
Executing: "C:\Program files\Picc\CCSC.exe" "flrwtest.C" +FH +DF +LN +T -A +M +Z +Y=9 +EA
*** Error 111 "E:\ats\A900_WD\BusCard\FLRWTEST\flrwtest.C" Line 12(7,49): Unknown keyword in #FUSES "NOLVP"
1 Errors, 0 Warnings.
Halting build on first failure as requested.
BUILD FAILED: Tue Sep 26 10:12:53 2006
If I were to remove NOLVP,
#include <18F6527.h>
#fuses HS,NOWDT,PROTECT,NOPUT,NOBROWNOUT //,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS, STREAM=RS485)
#use rs232(baud=9600, xmit=PIN_G1, rcv=PIN_G2, ERRORS, STREAM=UART)
it gave the following errors:
Executing: "C:\Program files\Picc\CCSC.exe" "flrwtest.C" +FH +DF +LN +T -A +M +Z +Y=9 +EA
*** Error 111 "E:\ats\A900_WD\BusCard\FLRWTEST\flrwtest.C" Line 12(7,51): Unknown keyword in #FUSES "NOBROWNOUT"
1 Errors, 0 Warnings.
Halting build on first failure as requested.
BUILD FAILED: Tue Sep 26 10:14:06 2006
Please advice. |
|
|
|
|
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
|