|
|
View previous topic :: View next topic |
Author |
Message |
Bisnouk
Joined: 21 Mar 2007 Posts: 14 Location: Avignon - France
|
[Solved] - 18F4620 - NO LVP - PIN B5 Problem |
Posted: Wed Mar 21, 2007 4:26 am |
|
|
I have a problem with PIN B5 of my PIC18F4620 (i 've tried with several other PIC18F4620)
I use the Fuse NOLVP, but when i try output_high on PIN_B5, nothing happen. On the other PIN B, it's OK.
I use CCS 4.023 but it's same with CCS 3.207
Sorry for my english.... i'm living in France !
Code: | #include <18F4620.h>
#device adc=10
#FUSES NOWDT
#FUSES WDT2048 //Watch Dog Timer uses 1:2048 Postscale
#FUSES H4 //High speed osc with HW enabled 4X PLL
#FUSES NOPROTECT //Code not protected from reading
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES BROWNOUT //Reset when brownout detected
#FUSES BORV28 //Brownout reset at 2.8V
#FUSES NOPUT //No Power Up Timer
#FUSES NOCPD //No EE protection
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOLVP //Low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOCPB //Boot Block Code not Protected
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES XINST //Extended set extension and Indexed Addressing mode enable
#FUSES NOPBADEN //PORTB pins are configured as digital I/O on RESET
#FUSES LPT1OSC //Timer1 configured for low-power operation
#FUSES MCLR //Master Clear pin enabled
#build(reset=0x800)
#build(interrupt=0x808)
#org 0x0000,0x07ff
void bootloader()
{
#asm
nop
#endasm
}
#use delay(clock=10000000,RESTART_WDT)
#define LED_2 PIN_B5
#include <stdlib.h>
#include <stddef.h>
void main()
{
delay_ms(200);
setup_psp(PSP_DISABLED);
port_b_pullups(FALSE);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
while(1)
{
output_high(LED_2);
delay_ms(200);
output_low(LED_2);
delay_ms(500);
}
} |
Last edited by Bisnouk on Tue Apr 10, 2007 1:05 am; edited 4 times in total |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 21, 2007 6:55 am |
|
|
CCS doesn't support the Extended Instruction Set. If it's enabled,
your code will do strange things. Change the fuse to NOXINST. |
|
|
Bisnouk
Joined: 21 Mar 2007 Posts: 14 Location: Avignon - France
|
|
Posted: Wed Mar 21, 2007 7:54 am |
|
|
Thank's for the reply, this is the explain of all mystery bug in my code... Some CCS 4.023 function bug.... only because i write XINST instead NOXINST
But, even if i change #FUSE NOXINST... the state of PIN B5 don't change.... :-(
I tried in direct ASM....
MOVLW 00
MOVWF F93 // set trisB = 0
BSF F8A.5 // set pin B5
nothing.... what i made wrong ??? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 21, 2007 9:41 am |
|
|
What external components are connected to pin B5 ? |
|
|
Bisnouk
Joined: 21 Mar 2007 Posts: 14 Location: Avignon - France
|
|
Posted: Wed Mar 21, 2007 10:03 am |
|
|
Only a LED via a resistor.
In fact, in my complex circuit, all I/O are used, also i want use the PORTB5 for drive a visu LED, so it don't work.
Also i wrote the sample code with a sample circuit. Only the PIC, Xtal, MCLR pull-up, B6 PIN LED (work fine) and B5 pin LED (don't work), and MAX 232 for serial cable on C6/C7 (i use Colt bootloader ).
I tried to change fuse (ex H4 -> HS), the program run more slowly.. so i'm sure that the bootloader work fine and change fuses values. |
|
|
Ttelmah Guest
|
|
Posted: Wed Mar 21, 2007 10:37 am |
|
|
One thing that leaps to mind, is that B5, is used n the CCS bootloader, as the trigger pin. This should not cause a problem directly, but might be an area to look.
The code as posted, won't work, so we can't really tell what you are doing (the dummy bootloader function is not terminated).
Best Wsihes |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 21, 2007 10:44 am |
|
|
Also if the LVP fuse is set, Pin B5 will stay low. I don't have a 18F4620
to test, but I tested it just now in hardware with a 18F4550 and that's
what it did. I would read the PIC with a programmer and check the
state of the LVP fuse, just to verify the true setting. |
|
|
Bisnouk
Joined: 21 Mar 2007 Posts: 14 Location: Avignon - France
|
|
Posted: Wed Mar 21, 2007 11:18 am |
|
|
Ttelmah wrote: | The code as posted, won't work, so we can't really tell what you are doing (the dummy bootloader function is not terminated). |
No, this code is working. When i drag it in this post, i delete a "}" with a blank line.
I've edit the original post and correcting the code.
I try to force fuse in my program (see below). If i change HS -> H4 (first fuse 0xC600 or 0xC200, the program speed change, also i think that my program can modify fuse values.
Code: | #include <18F4620.h>
#device adc=10
#FUSES NOWDT
#FUSES WDT2048 //Watch Dog Timer uses 1:2048 Postscale
#FUSES HS //High speed osc
#FUSES NOPROTECT //Code not protected from reading
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES BROWNOUT //Reset when brownout detected
#FUSES BORV28 //Brownout reset at 2.8V
#FUSES NOPUT //No Power Up Timer
#FUSES NOCPD //No EE protection
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOLVP //Low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOCPB //Boot Block Code not Protected
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES NOXINST //Extended set extension and Indexed Addressing mode enable
#FUSES NOPBADEN //PORTB pins are configured as digital I/O on RESET
#FUSES LPT1OSC //Timer1 configured for low-power operation
#FUSES MCLR //Master Clear pin enabled
#build(reset=0x800)
#build(interrupt=0x808)
#org 0x0000,0x07ff
void bootloader()
{
#asm
nop
#endasm
} // Reserve l'espace pour le bootloader
#use delay(clock=10000000)
#define LED_2 PIN_B5
#define LED_3 PIN_B7
void main()
{
int16 data[7]={
0xC200,0x1617,0x8500,0x0081,0xC00F,0xE00F,0X400F
};
write_configuration_memory(data,7);
while(1)
{
output_high(LED_2);
output_high(LED_3);
delay_ms(200);
output_low(LED_2);
output_low(LED_3);
delay_ms(500);
}
} |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 21, 2007 11:22 am |
|
|
Well, it probably has to be one of these things:
1. The pin driver is dead or damaged on that PIC.
2. The external circuit is loading down the pin too much,
so that it can't be driven high.
3. The LVP fuse is really set (even though you think it is not).
4. The pin is somehow allocated for use by the Colt bootloader,
as Ttelmah says.
You should investigate each one of those possible reasons in detail
and prove that it's not true. Don't assume anything.
Last edited by PCM programmer on Wed Mar 21, 2007 11:24 am; edited 1 time in total |
|
|
Ttelmah Guest
|
|
Posted: Wed Mar 21, 2007 11:23 am |
|
|
A lot of bootloader's, won't change all the fuses. Are you _sure_ that your bootloader does set this fuse.
Best Wishes |
|
|
Bisnouk
Joined: 21 Mar 2007 Posts: 14 Location: Avignon - France
|
|
Posted: Wed Mar 21, 2007 11:38 am |
|
|
PCM programmer wrote: |
1. The pin driver is dead or damaged on that PIC.
|
I have the same problem with 8 differents PIC18F4620.
PCM programmer wrote: |
2. The external circuit is loading down the pin too much,
so that it can't be driven high.
|
I drive a LED and it work well if i connecte this LED on another PINB
PCM programmer wrote: |
3. The LVP fuse is really set (even though you think it is not).
|
This is the only way i think !
PCM programmer wrote: |
4. The pin is somehow allocated for use by the Colt bootloader,
as Ttelmah says.
|
No, bootloader use only RX/TX pin (port C)
Ttelmah wrote: |
A lot of bootloader's, won't change all the fuses. Are you _sure_ that your bootloader does set this fuse.
|
Maybe, but is my program don't force fuses after bootloader execution with this code ?
Code: |
int16 data[7]={
0xC200,0x1617,0x8500,0x0081,0xC00F,0xE00F,0X400F
};
write_configuration_memory(data,7);
|
tomorow, i'll try other bootloader and compare results.
Thank's for the replies, i feed back here when i find the cause. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 21, 2007 2:49 pm |
|
|
Quote: |
Maybe, but is my program don't force fuses after bootloader
execution with this code ?
int16 data[7]={
0xC200,0x1617,0x8500,0x0081,0xC00F,0xE00F,0X400F
};
write_configuration_memory(data,7);
|
Download the 18F4620 Programming specification:
http://ww1.microchip.com/downloads/en/DeviceDoc/39622j.pdf
Look at Section 5.3, Single-Supply ICSP Programming, on page 37.
It says:
Quote: | However, the LVP bit may only be programmed
by entering the High-Voltage ICSP mode,
where MCLR/VPP/RE3 is raised to VIHH. |
And also:
Quote: | While in Low-Voltage ICSP mode, the RB5 pin can
no longer be used as a general purpose I/O. |
This means your code above can't program the LVP bit
into NOLVP mode. It also likely means that when the
Colt Bootloader was programmed into your PIC, that
the config bits were set for LVP mode. You need to
re-program your PIC with a normal programmer (ICD2)
and set the config bit to "Disable Low Voltage Programming". |
|
|
jpvr
Joined: 18 Mar 2007 Posts: 9
|
|
Posted: Wed Mar 21, 2007 3:31 pm |
|
|
Bonsoir Ttelmah,
Puis je te demander o� tu as trouver le bootloader " Colt " ???
En es - tu content ???
Merci,
Jean - Pierre |
|
|
Ttelmah Guest
|
|
Posted: Wed Mar 21, 2007 3:37 pm |
|
|
It is Bisnouk who is using the Colt bootloader, not me. I can't answer for how well it works.
Best Wishes |
|
|
jpvr
Joined: 18 Mar 2007 Posts: 9
|
|
Posted: Wed Mar 21, 2007 3:50 pm |
|
|
Hello Ttelmah,
You have right, excuse me for the mistake.
Best regards and good night,
Jean - Pierre |
|
|
|
|
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
|