PDA

View Full Version : Madness, 18F2550!



tom
- 10th February 2007, 13:27
Dear friends, please help or I'll go crazy. This seek simple code doesn't work
on 18F2550. Of course, it works on good old '876.


@ __CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_1_1L
@ __CONFIG _CONFIG1H, _FOSC_HS_1H
@ __CONFIG _CONFIG2L, _PWRT_ON_2L
@ __CONFIG _CONFIG2H, _WDT_OFF_2H
@ __CONFIG _CONFIG3H, _MCLRE_ON_3H & _PBADEN_OFF_3H
@ __CONFIG _CONFIG4L, _STVREN_OFF_4L & _LVP_OFF_4L

define OSC 20
define LCD_EREG PORTC
define LCD_EBIT 1

i var byte
pause 100

lcdout $fe,1,"MADNESS!!!"
pause 1500
i=15
pause 500
lcdout $fe,1,dec3 i
pause 1500
kraj: goto kraj
end

when I start pic first time I get value 164 on LCD, and after that every reset
gives value 004 ?????!!!!! Am I crazy or what? I try different values for i but
never gets the correct value. I try with i defined as word - the same thing.

BobK
- 10th February 2007, 14:00
Hello,

Taking a basic stab at your problem I see:

Where's the rest of the DEFINES for the LCD? Assuming you're using the defaults of connecting to PortA then where are the settings to disable the Analog and converting the A/D pins to digital? You also need to disable the comparator module.

There's no reason to go MAD, just sit back and relax. Read the datasheet and keep trying!

BobK

tom
- 10th February 2007, 14:26
Sorry, I forgot to paste that part of code:


@ __CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_1_1L
@ __CONFIG _CONFIG1H, _FOSC_HS_1H
@ __CONFIG _CONFIG2L, _PWRT_ON_2L
@ __CONFIG _CONFIG2H, _WDT_OFF_2H
@ __CONFIG _CONFIG3H, _MCLRE_ON_3H & _PBADEN_OFF_3H
@ __CONFIG _CONFIG4L, _STVREN_OFF_4L & _LVP_OFF_4L

define OSC 20
define LOADER_USED 1
define LCD_EREG PORTC
define LCD_EBIT 1

i var word
pause 100

CMCON=7
CCP1CON=0
ADCON1=$0F
ADCON0=0

lcdout $fe,1,"MADNESS!!!"
pause 1000
i=150
pause 1000
lcdout $fe,1,dec3 i
pause 1000
kraj: goto kraj
end

but still the same thing, and the interesting fact is that the code
working OK - the value written on lcd is correct when i program
pic through bootloader!

mister_e
- 10th February 2007, 17:05
For some odd reasons,

LCDOUT $FE,1,#I
work

tom
- 10th February 2007, 18:19
I'm very disappointed because I have a huge application which controls
solar machine and it works great and my customer is very satisfied.
Because of new features planing to add I have to migrate the whole
design to 18F. And I am stucked for almoust a month without any success.
The program is acting very strange - don't react on buttons, don't count time... But when I use bootloader from MCS everything WORKS as expected!
Of course, my customer have only ICPROG they don't use bootloader so what should I do, start to write the whole application from the beginning in C?????

mister_e
- 10th February 2007, 18:30
Well, do as you wish... but i doubt it will solve the problem.

At least make sure the Config fuses are correctly transfered from MCS to your XYZ programmer software and that your XYZ software is set to program those fuses.

I'd never trusted ICPROG and ALL freebies one anyways, and guess what? I think it's the main problem here.

When you don't use the bootloader, how do you program your PIC, In-circuit?, on a ZIFF (or else) socket? Wich programmer/interface. Is PGM tied to GND (or at very least loaded to GND)?

Did you do a 'programming check' once it's programmed?

Any schematic of your stuff? ... just in case.

EDIT: i remind Malc-C already had problem programming this PIC with software like that... no coincidence at all :D

EDIT #2 : ICPROG don't have the 18F2550 in it's list... at least if their wonderful website is up-to-date...

BigWumpus
- 10th February 2007, 20:24
I stop using ICPROG when starting using the 18Fxxxx ....
ICPROG could not understand the EEPROM- or DATA-values.

tom
- 10th February 2007, 21:27
Sory guys,
my mistake due to hurry, I use WinPic programmer and yes, I checked all fuses that I programmed. The LED blinking program works very well so I think
that the programmer is doing his job very well.

Archangel
- 10th February 2007, 22:27
To use a bootloader you add to code


define LOADER_USED 1

and if I understand what this does correctly, it moves everything down the stack, some fixed size (4 bits, or is it 4 bytes?) anyway, what happens if you forget to comment out this code when not using bootloader?
If as mister_e says ICPROG doesn't support 18F 2550 it's never going to program it properly.

Archangel
- 10th February 2007, 22:31
Of course, my customer have only ICPROG they don't use bootloader so what should I do, start to write the whole application from the beginning in C?????
As a stopgap, you could program chips for him, until you sort this out.

Bruce
- 10th February 2007, 23:00
Have you tried the 'exact' same config fuse settings that are in your loader file
when programming it without the loader?

tom
- 11th February 2007, 11:00
That helps Bruce!
By careful comparision of every fuse programmed with and without bootloader I noticed some XINST=Extended Instruction Set Enable Bit which was dissabled in working version and enabled in non working version! In WinPicProgrammer this fuse is called "ENHCPU Extended CPU Enable". This fuse is related with some 18F specific data addressing techniques. To be sure that this fuse is my problem I reprogrammed several times exactly the same program (with other fuses the same) with XINST OFF and XINST ON and YES! With XINST ON the program is acting very strange and completely unfunctional. I try with programmer and with bootloader, symptoms are the same. So, dear friends, thanks everyone for help and write down in your notebook of 18FXXX' secrets following line:


@ __CONFIG _CONFIG4L, _XINST_OFF_4L


cheers!