CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Just getting started problems...

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
SBS



Joined: 15 Aug 2005
Posts: 18

View user's profile Send private message

Just getting started problems...
PostPosted: Tue Oct 04, 2005 9:19 pm     Reply with quote

Ok.. I have my new PIC18F4620, ICD 2, CCS compiler...

I'm powering the chip from the ICD 2 programmer. I'm running the following code:


#include <18F4620.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

void main() {

// printf("Press any key to begin\n\r");
// getc();
// printf("1 khz signal activated\n\r");

while (TRUE) {
output_high(PIN_B0);
delay_ms(1000);
output_low(PIN_B0);
delay_ms(1000);
}
}


From what MPLAB tells me, it looks like everything is OK. I'm putting a multimeter on RB0 (pin 33) and I'm not seeing any voltages up or down... just a steady 0.23 volts.

Any suggestions? Am I missing somethings?

Strangely enough... I ran the program without connecting my oscillator to the chip. MPLAB didn't say there was any problem. Now after connecting my 4 MHz oscillator, still doesn't work.

Any help?

Thanks,
Sal
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Tue Oct 04, 2005 9:38 pm     Reply with quote

What board are you using? Any more info would be helpful to the experts.

Strangely enough, I am using a 18F4620 and this evening I was chopping and hacking a prototype and scabbed a LED on to RB0. It didn't work until I used:

Code:

set_tris_b(0x00);    //set port as output


So, I'm guessing the port won't work as an output until you specifically set it as one. Merely setting the output high or low on a pin won't necessarily make it so.

Good luck,

John
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Oct 04, 2005 9:45 pm     Reply with quote

Are you using an oscillator or a crystal ?

If you're using an oscillator, then try using the EC (or ECIO) fuse
instead of HS.

If you're using a crystal, do you have 22pf capacitors connected from
each side of the crystal to ground ?

Also, for future use, add the ERRORS parameter to the #use rs232
statement. It will prevent the UART from locking up if an overrun
error occurs.
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)


Also, can you post your version of the compiler ? This will be a number
like 3.191, 3.325, etc.
------------------------------
To jecottrell:

In his program as posted, he's using standard i/o mode (which is
the default mode in CCS). In that mode, the compiler automatically
inserts code to setup the proper TRIS, if you use the CCS functions
such as output_high(), output_low(), etc.
So his code is OK.
SBS



Joined: 15 Aug 2005
Posts: 18

View user's profile Send private message

PostPosted: Tue Oct 04, 2005 9:54 pm     Reply with quote

I'm not using a prototyping board... just a breadboard.

I've bot the VSS and VDD from the ICD 2 going to the chip (both VDD and VSS inputs). I've got a 4 MHz crystal oscillator connected to OSC1 and OSC2. I have 15 pf capacitors between the crystal oscillator terminals and ground. And I've got all of the other ICD 2 connections to the chip.

That's it.

Is there anything else I need? I'm concerned that MPLAB said that it programmed the device propertly and didn't give me any errors when I ran the code when I didn't have the oscillator on.

I think I'm missing something major. All I have to do is program my device from MPLAB and hit RUN, right? What am I missing?

Thanks,
Sal
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Oct 04, 2005 10:28 pm     Reply with quote

If you're powering your board from the ICD2, then you need
to configure MPLAB to do that. Go to the Programmer menu,
then to Settings, and then to the Power tab. There's a checkbox
labeled "Power target circuit from MPLAB ICD2 (5v Vdd).
You need to select that box, and click apply. Then click the
Update button, and make sure the Target Vdd is approximately 5v.

I tested this just now with a PicDem2-Plus board, and target Vdd = 4.77v.
SBS



Joined: 15 Aug 2005
Posts: 18

View user's profile Send private message

PostPosted: Tue Oct 04, 2005 10:47 pm     Reply with quote

Thanks for the help. I have been using it with the "powered from ICD 2" option. I have a Vdd of 4.82 volts.

Here is what the status window says:

Connecting to MPLAB ICD 2
...Connected
Setting Vdd source to MPLAB ICD 2
Target Device PIC18F4620 found, revision = a4
...Reading ICD Product ID
Running ICD Self Test
...Passed
MPLAB ICD 2 Ready

My concern may be that my oscillator isn't working. But I can put breakpoints in my code and it will stop at them. This means that the program is executing on the chip right?

When I pull out the oscillator everything in MPLAB functions exactly the same. On the bottom of the screen the "running" status bar shows that its running. How can it be running without an oscillator?

Thanks,
Sal
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Oct 04, 2005 11:24 pm     Reply with quote

Yes, the PIC's oscillator must be running for ICD2 to "connect" to
the PIC. If the oscillator is not running, you'll get an ICD0083 and
a ICD0069 error displayed in MPLAB when you try to connect.

What is your version of the compiler ?
This is a 4-digit number that you can find at the top of the .LST file,
which will be in your project directory after a successful compilation.
It will be a number like 3.191, or 3.235, etc.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Tue Oct 04, 2005 11:26 pm     Reply with quote

Do you have the ICD2 selected as a programmer or as a debugger?

Maybe you have it selected as a programmer and the simulator as the debugger.
Guest








PostPosted: Wed Oct 05, 2005 6:44 am     Reply with quote

MPLAB tells me that I can't have ICD 2 as programmer and debugger... so now I have ICD 2 as debugger and programmer as NONE.

I get the following errors now:

MPLAB ICD 2 Ready
ICD0083: Target not in debug mode, unable to perform operation
Running Target
ICD0083: Target not in debug mode, unable to perform operation
ICD0069: Unable to run target
MPLAB ICD 2 Ready


CCS PCH C Compiler, Version 3.235

Thanks,
Sal
Guest








PostPosted: Wed Oct 05, 2005 6:48 am     Reply with quote

I got it working!!!

My LED is flashing on and off! Thanks so much to all of your for your help. I think I just had a configuration problem.

Thanks again,
Sal
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Wed Oct 05, 2005 6:49 am     Reply with quote

So what did you have selected as the debugger?

Check you connections again. Look up the schematic for say one of the PICDEM boards and make sure you have the ICD connected as they do. Also make sure ALL Vss and Vdd are connected. You can also add the ICD = TRUE statement.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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