|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
LCD Project with 18f4525 |
Posted: Tue Jan 02, 2007 1:30 pm |
|
|
I'm working on interfacing an LCD with an 18f4525. I'm having an issue with the program memory erasing upon power down. When I turn on the pic, the lcd will power up with the text showing. When I power down and power back up again, nothing will show up on the LCD. Are there settings in CCS that protect the program memory upon power down? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jan 02, 2007 1:42 pm |
|
|
How do you know the program memory in the PIC is being erased ?
Have you connected a programmer to it, and done a Verify operation
against your original HEX file ?
My guess is that you may have a power-on reset problem, and you
just need to enable the BROWNOUT and PUT fuses.
Also, it's possible that your LCD requires a longer power-on delay
than the 15 ms which is used in the CCS lcd.c driver. You could
try increasing it to 30 ms. |
|
|
Guest
|
|
Posted: Wed Jan 03, 2007 5:59 am |
|
|
Hi PCM,
Right now, i have the 18f4525 placed on a breadboard with a LED connected to pin a1. The code below instructs the pic to blink the LED, which it does, but after about 10 seconds or so, the LED will just turn off. Then, when I power off and on the PIC, the LED will not turn on again until I reprogram it. Perhaps i have some of the settings wrong?
Code: |
#include <18f4525.h>
#include <stdlib.h>
#fuses INTRC_IO, NOWDT, PUT , BROWNOUT, NOLVP
#use delay(clock=8000000)
void main(void)
{
setup_oscillator(OSC_8MHZ);
while (true){
output_high(PIN_A1);
delay_ms(100);
output_low(PIN_A1);
delay_ms(100);
}
}
|
|
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Wed Jan 03, 2007 7:27 am |
|
|
From Microchip PIC18F4525 Datasheet:
On a Power-on Reset, RA5 and RA3:RA0 are configured as analog inputs
and read as ī0ī. RA4 is configured as digital input.
To put the contents of the output latch on the selected pin (PIN_A1) include
the following statements in the initialization procedure:
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
You didnīt post your compiler version.
Some versions do not configure properly the 18F4525 MCLR setting in the
configuration word (FUSES).
Humberto |
|
|
Guest
|
|
Posted: Wed Jan 03, 2007 9:12 am |
|
|
Hi Humberto,
I'm using CCS 4.0.0.207. This is the code I have so far, and I still have the same problems. I don't believe it's my hardware because i've written the same sample code in C18 and it works fine.
The program will work when i power up the first time, but if i leave it on, the LED will turn off permanantly. If I power off and power on again, the LED will not re start. If I reburn the PIC, everyone will work again temporarily.
Code: |
#include <18f4525.h>
#include <stdlib.h>
int lcdNum=0;
//#include <FlexLCD_ccs_TEST.c>
#fuses INTRC_IO, NOWDT, PUT , BROWNOUT, NOLVP, NOPROTECT
#use delay(clock=8000000)
void main(void)
{
setup_oscillator(OSC_8MHZ);
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
SET_TRIS_A(0x00);
SET_TRIS_B(0x00);
SET_TRIS_C(0x00);
SET_TRIS_D(0x00);
SET_TRIS_E(0x00);
while (true){
output_high(PIN_A1);
delay_ms(100);
output_low(PIN_A1);
delay_ms(100);
}
}
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jan 03, 2007 9:34 am |
|
|
That's not the compiler version. Look at the top of the .LST file
in your project directory to get the version. It will be a number
in this format: N.xxx
Examples: 3.249, 4.016, 4.018, etc. |
|
|
Guest
|
|
Posted: Wed Jan 03, 2007 9:49 am |
|
|
CCS PCH C Compiler, Version 4.018, 36750 03-Jan-07 11:53 |
|
|
Ttelmah Guest
|
|
Posted: Wed Jan 03, 2007 11:26 am |
|
|
First, read the comments about the V4 CCS compilers, download the 3.249 compiler (the last reasonably working version), and try this.
However, that having been said, the code generated for the simple 'test' program does not seem to have anything wrong in 4.018. Also a code fault, is unlikely to give the behaviour you are reporting. So, the question arises, have you tried another chip?. Erasing code memory, on a PIC, actually takes quite a bit of work. There is a protection system in the chip, to make it very nearly impossible to erase the memory accidentally. None of the code here, even 'goes near' this protection, so there are a few possibilities.
1) What is connected to MCLR?. You are not using the NOMCLR fuse, so this pin will be acting as a reset. It is possible that this is floating low, and resetting the PIC.
2) As PCM programmer has already said, have you tried verifying the chip after it has 'failed'. This will prove if the memory is being lost. If it is, then the 'odds' are that you actually have a faulty chip. The memory can go into a mode where it 'leaks' it's contents, if it is poorly programmed (overvoltage on the programming pin), or a lot of programming cycles are performed (many thousands...).
I'd say the odds are that you don't have a pull up on MCLR.
Best Wishes |
|
|
Guest
|
|
Posted: Wed Jan 03, 2007 11:40 am |
|
|
Ttelmah,
Thank you so much, it was the NOMCLR fuse that I didn't have set. I had compared the code, and yes you are correct, the program memory was not affected. I've also tried using mutiple pics with the same result.
Thank you all for your help.. i have a feeling that I will be back.. |
|
|
|
|
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
|