|
|
View previous topic :: View next topic |
Author |
Message |
microchip
Joined: 14 Mar 2005 Posts: 3
|
18F458 Problem |
Posted: Mon Mar 14, 2005 1:14 pm |
|
|
Hello,
If i used the PROTECT configuration word in ccs then EEPROM writing
is off.If I read the EEPROM after writing some data I always get the
255.Can any one help me why it is happened
Thanks
Regards,
Sohail Anjum |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Mar 14, 2005 1:53 pm |
|
|
The 18F458 data sheet says that you can always read/write
the data eeprom:
Quote: | 24.4.2 DATA EEPROM CODE PROTECTION
The CPU can continue to read and write data
EEPROM, regardless of the protection bit settings. |
You need to post a short test program, complete with the
#fuses statement.
You also need to post:
1. Your version of the compiler. (ie., 3.218, 3.219, 3.221, etc).
2. Your programmer type (ie., PicStart-Plus, ICD2, Warp13a, etc.)
3. The Vdd voltage you are using for your PIC. (ie., +5v, +3.3v, etc.) |
|
|
microchip
Joined: 14 Mar 2005 Posts: 3
|
|
Posted: Mon Mar 14, 2005 2:10 pm |
|
|
Hello
the complete test program is below
"
#include <18F458.h>
#fuses H4,NOWDT,NOLVP,CPD,NOPUT,NOBROWNOUT,NOOSCSEN,NOWRTD
,PROTECT
#use delay(clock=40000000)
#define PORTB 0xF81
#bit LED = PORTB.7
#use fast_io(B)
#use fast_io(c)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,bits=8,parity=n)
void initSystem();
static char data;
void main() {
initSystem();
putc('T');
write_eeprom(0,'A');
data = read_eeprom(0);
putc(data);
while (1){
LED=1;
delay_ms(300);
LED=0;
delay_ms(300);
}//end while 1
}// end Functoin main
void initSystem(){
set_tris_b(0b01111111);
set_tris_c(0b10111111);
LED=0;
}// end Function initSystem
"
this program send 255 always after start up in serial port
if i off the PROTECT then it send 'A' .
compiler version is 3.149
i am using the ICD for program the uc.
But problem with PROTECT if i remove it , work is fine
what is problem with it ?
Regards,
Sohail Anjum |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Mar 14, 2005 2:45 pm |
|
|
You didn't say what the Vdd voltage is for the PIC. (+3.3v or +5v or ?)
Also, your program is too complex. You should use a much
more simple program, such as the one shown below.
For example, you said that you're getting 0xFF back.
But how do you know that ?, because your program is using
putc() which sends a binary value to your terminal program.
I think 0xFF may display nothing on the terminal screen.
It's better to send the ascii hex value to the terminal, as
I'm doing in the program below. Then, you really see
what you're reading from the eeprom.
The following program should display: T 41 42
Once you get this program working, then experiment with
the protection settings.
You will notice that I have turned off everything that is not
essential for this test. For example, don't use the 4x PLL
mode. It might not be working. So shut it down and run
at 1x mode, with the HS fuse. Also, I have left NOBROWNOUT
in place, because you didn't post your Vdd voltage.
Code: | #include <18F458.h>
#fuses HS, NOWDT, NOPUT, NOBROWNOUT, NOLVP
#use delay(clock=10000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
void main()
{
char data;
printf("T ");
write_eeprom(0,'A');
data = read_eeprom(0);
printf("%X ", data);
write_eeprom(0,'B');
data = read_eeprom(0);
printf("%X ", data);
while(1);
} |
|
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Mon Mar 14, 2005 3:24 pm |
|
|
Sohail Anjum wrote:
Quote: |
But problem with PROTECT if i remove it , work is fine
what is problem with it ?
|
Analizing the configuration words listed at the end of the .lst file you
can know why.
The meaning of each fuses you can find it in:
http://ww1.microchip.com/downloads/en/DeviceDoc/41159d.pdf
Chapter 24.1 Configuration bits
The PIC18F458 has a set of 7 Configuration Registers
wich can be accessed only during programming time.
Below I pasted an example:
Code: |
Configuration Fuses:
Word 1: 2600 H4 NOOSCSEN
Word 2: 0E0E BROWNOUT WDT128 NOWDT BORV20 PUT
Word 3: 0000
Word 4: 0081 STVREN NODEBUG NOLVP
Word 5: 400F NOPROTECT CPD NOCPB
Word 6: E00F NOWRT NOWRTD NOWRTB NOWRTC
Word 7: 400F NOEBTR NOEBTRB
|
Hope this help.
Humberto |
|
|
microchip
Joined: 14 Mar 2005 Posts: 3
|
|
Posted: Tue Mar 15, 2005 12:21 pm |
|
|
Hello
i am using the my own terminal software which can display data in 4 formate ASCII,HEX,Binary and Octal.But now also check with hyperterminal problem is same.
VDD voltage is 5V
I also used the following code
#include <18F458.h>
#fuses HS, NOWDT, NOPUT, NOBROWNOUT, NOLVP,PROTECT
#use delay(clock=10000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
void main()
{
char data;
printf("T ");
write_eeprom(0,'A);
data = read_eeprom(0);
printf("%X ", data);
write_eeprom(0,'B');
data = read_eeprom(0);
printf("%X ", data);
while(1);
}"
"
if i removed the PROTECT than is working fine send the
41 42 but if i used the PROTECT than it send
FF FF
the configuration word in .lst is
Configuration Fuses:
Word 1: 2200 HS NOOSCSEN
Word 2: 0E0D NOBROWNOUT WDT128 NOWDT BORV20 NOPUT
Word 3: 0000
Word 4: 0081 STVREN NODEBUG NOLVP
Word 5: C000 PROTECT NOCPD NOCPB
Word 6: E00F NOWRT NOWRTD NOWRTB NOWRTC
Word 7: 400F NOEBTR NOEBTRB
it any bug in 18F458 or else problem.But what problem???
thanks for reply me
Regards
Sohail Anjum |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Mar 15, 2005 3:05 pm |
|
|
I tested the program on my 18F458 board, and it works OK with
the PROTECT fuse set. My board runs at 4 MHz, so I changed
the #use delay() setting, and also my board runs better if PUT
and BROWNOUT are enabled. But those are the only changes
I made.
I'm using PCH vs. 3.188. I get this output:
T 41 42 |
|
|
|
|
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
|