Exact match. Not showing close matches.
PICList
Thread
'[PIC] Unable to get C program to work'
2007\02\23@111943
by
Martin Klingensmith
|
I'm trying to write an extremely simple program for a 30F3010 using the
Microchip C30 tool. This is my entire program:
#include <p30f3010.h>
void init()
{
TRISB = 0x00;
return;
}
void delay()
{
int x=0;
for(x=0;x<10000;x++){}
return;
}
int main (void)
{
init();
while (1)
{
PORTB = 0xFF;
delay();
PORTB = 0x00;
delay();
}
return 0;
}
I don't know how it could be much simpler. It compiles, I program it with my
USBProg, and nothing happens.
I have set the oscillator to Internal RC - High Speed and the WDT is off. I
attach an oscilloscope and it's dead as can be. I've tried clocking it
externally with a function generator and I get the same thing. Yesterday I
tried an 18F1220 with nearly the same exact program and the clock seems to
run for a few ms and then quit. I'm getting really frustrated with how much
time I'm wasting trying to get my dev. tools to work. Do you have any
advice?
Thanks,
--
Martin
2007\02\23@120149
by
Andre Abelian
Martin,
Your code is for 8 bit parts you need to work with
16 bit values. like TRISB = 0x0000; PORTB = 0xFFFF; etc
Andre
{Original Message removed}
2007\02\23@122957
by
peter green
|
{Quote hidden}> -----Original Message-----
> From:
spam_OUTpiclist-bouncesTakeThisOuT
mit.edu [
.....piclist-bouncesKILLspam
@spam@mit.edu]On Behalf
> Of Martin Klingensmith
> Sent: 23 February 2007 16:19
> To:
piclist
KILLspammit.edu
> Subject: [PIC] Unable to get C program to work
>
>
> I'm trying to write an extremely simple program for a 30F3010 using the
> Microchip C30 tool. This is my entire program:
>
> #include <p30f3010.h>
>
> void init()
> {
> TRISB = 0x00;
>
> return;
> }
>
> void delay()
> {
> int x=0;
> for(x=0;x<10000;x++){}
> return;
> }
>
> int main (void)
> {
> init();
> while (1)
> {
> PORTB = 0xFF;
> delay();
> PORTB = 0x00;
> delay();
> }
> return 0;
> }
>
> I don't know how it could be much simpler. It compiles, I program
> it with my
> USBProg, and nothing happens.
> I have set the oscillator to Internal RC - High Speed and the WDT
> is off. I
> attach an oscilloscope and it's dead as can be. I've tried clocking it
> externally with a function generator and I get the same thing. Yesterday I
> tried an 18F1220 with nearly the same exact program and the clock seems to
> run for a few ms and then quit. I'm getting really frustrated
> with how much
> time I'm wasting trying to get my dev. tools to work. Do you have any
> advice?
for the 18F chip make sure low voltage program is disabled, i don't know if the 30F chips have that option but if they do you might want to check it for them too
also note that if you set your configuration bits using the mplab gui rather than through code they will NOT be in the hex file the compiler generates.
2007\02\23@123240
by
olin piclist
Martin Klingensmith wrote:
> I don't know how it could be much simpler. It compiles, I program it
> with my USBProg, and nothing happens.
You're not specifying the config bits, so they end up in whatever the erased
state is (the erased state for config bits is not necessarily 1 like it is
for all other non-volatile bits in an PIC).
********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014. Gold level PIC consultants since 2000.
2007\02\23@125120
by
Martin Klingensmith
It was the low-voltage programming pin. I didn't think of that because I've
never had a problem with it before.
I'll be specifying the config bits in the program from now on (like they
should be)
The PGM pin was floating, causing strange things to happen.
--
Martin
On 2/23/07, Olin Lathrop <.....olin_piclistKILLspam
.....embedinc.com> wrote:
{Quote hidden}>
> Martin Klingensmith wrote:
> > I don't know how it could be much simpler. It compiles, I program it
> > with my USBProg, and nothing happens.
>
> You're not specifying the config bits, so they end up in whatever the
> erased
> state is (the erased state for config bits is not necessarily 1 like it is
> for all other non-volatile bits in an PIC).
>
>
> ********************************************************************
> Embed Inc, Littleton Massachusetts,
http://www.embedinc.com/products
> (978) 742-9014. Gold level PIC consultants since 2000.
> -
2007\02\23@133752
by
Harold Hallikainen
|
Which reminds me... How do you set config bits in C30? MPLAB Help tells us
how to do it for C18, but I don't see how to do it for C30.
THANKS!
Harold
{Quote hidden}> It was the low-voltage programming pin. I didn't think of that because
> I've
> never had a problem with it before.
> I'll be specifying the config bits in the program from now on (like they
> should be)
> The PGM pin was floating, causing strange things to happen.
> --
> Martin
>
> On 2/23/07, Olin Lathrop <
EraseMEolin_piclistspam_OUT
TakeThisOuTembedinc.com> wrote:
>>
>> Martin Klingensmith wrote:
>> > I don't know how it could be much simpler. It compiles, I program it
>> > with my USBProg, and nothing happens.
>>
>> You're not specifying the config bits, so they end up in whatever the
>> erased
>> state is (the erased state for config bits is not necessarily 1 like it
>> is
>> for all other non-volatile bits in an PIC).
>>
>>
>> ********************************************************************
>> Embed Inc, Littleton Massachusetts,
http://www.embedinc.com/products
>> (978) 742-9014. Gold level PIC consultants since 2000.
>> --
2007\02\23@143245
by
olin piclist
Martin Klingensmith wrote:
> It was the low-voltage programming pin.
I thought you said this was on a 30F3010. The 30F doesn't have the LVP
feature and therefore no PGM pin.
********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014. Gold level PIC consultants since 2000.
2007\02\23@153208
by
Martin Klingensmith
|
I found this on line 2158 of p30f3010.h:
Setting configuration fuses using macros:
==========================================
Macros are provided which can be used to set configuration fuses:
For e.g., to set the FOSC fuse using a macro above, the following line of
code can be pasted before the beginning of the C source code.
_FOSC(CSW_FSCM_ON & ECIO_PLL16);
This would enable the external clock with the PLL set to 16x and further,
enable clock switching and failsafe clock monitoring.
Similarly, to set the FBORPOR fuse, paste the following :
_FBORPOR(PBOR_ON & BORV_27 & PWRT_ON_64 & MCLR_DIS);
This would enable Brown-out Reset at 2.7 Volts and initialize the Power-up
timer to 64 milliseconds and configure the use of the MCLR pin for I/O.
Given below, is a complete list of settings valid to each of the fuses:
(Paste the ones relevant to your application before the beginning of C
source code.)
..
etc
..
--
Martin
On 2/23/07, Harold Hallikainen <harold
spam_OUThallikainen.org> wrote:
{Quote hidden}>
> Which reminds me... How do you set config bits in C30? MPLAB Help tells us
> how to do it for C18, but I don't see how to do it for C30.
>
> THANKS!
>
> Harold
>
>
> > It was the low-voltage programming pin. I didn't think of that because
> > I've
> > never had a problem with it before.
> > I'll be specifying the config bits in the program from now on (like they
> > should be)
> > The PGM pin was floating, causing strange things to happen.
> > --
> > Martin
> >
> > On 2/23/07, Olin Lathrop <
@spam@olin_piclistKILLspam
embedinc.com> wrote:
> >>
> >> Martin Klingensmith wrote:
> >> > I don't know how it could be much simpler. It compiles, I program it
> >> > with my USBProg, and nothing happens.
> >>
> >> You're not specifying the config bits, so they end up in whatever the
> >> erased
> >> state is (the erased state for config bits is not necessarily 1 like it
> >> is
> >> for all other non-volatile bits in an PIC).
> >>
> >>
> >> ********************************************************************
> >> Embed Inc, Littleton Massachusetts,
http://www.embedinc.com/products
> >> (978) 742-9014. Gold level PIC consultants since 2000.
> >> --
2007\02\23@154410
by
Martin Klingensmith
I was hasty in writing my reply because I had to leave for a class. I meant
to say that I had gotten my 18F program to work. I just set the config. bits
for my 30F program and it works fine. The config. bits have been set like
this:
_FOSC(CSW_FSCM_OFF & FRC_PLL16);
_FWDT(WDT_OFF);
_FGS(CODE_PROT_OFF);
_FBORPOR(MCLR_EN);
Thanks,
Martin
On 2/23/07, Olin Lathrop <KILLspamolin_piclistKILLspam
embedinc.com> wrote:
{Quote hidden}>
> Martin Klingensmith wrote:
> > It was the low-voltage programming pin.
>
> I thought you said this was on a 30F3010. The 30F doesn't have the LVP
> feature and therefore no PGM pin.
>
>
> ********************************************************************
> Embed Inc, Littleton Massachusetts,
http://www.embedinc.com/products
> (978) 742-9014. Gold level PIC consultants since 2000.
> -
2007\02\23@163112
by
Phillip Coiner
Hi Harold
There is a document on the microchip web site some where that lists the new
way of programming the config bits with a pragma statement...at least in C18
but the Microchip web site is so slow I can't find it.
The document has the pragma listings for every device supported by C18 I
just printed out the page for my device .......and apparently now I've lost
it because I can't find it any where in my office.
I don't see why it would be any different/they wouldn't do the same thing
for the C30..........but of course I have no idea what C30 is/does/could do.
This is how it looks for an 18F6620 in C18 in my current project
#pragma config OSC = HS, OSCS = OFF,PWRT = ON, BOR = ON, BORV = 25, WDT =
OFF, WDTPS = 1, LVP = OFF, CCP2MUX = OFF, STVR = ON
Phillip
Things should be as simple as possible but no simpler
Phillip Coiner
CTO, GPS Source, Inc.
Your source for quality GNSS Networking Solutions and Design Services, Now!
{Original Message removed}
More... (looser matching)
- Last day of these posts
- In 2007
, 2008 only
- Today
- New search...