Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Really Newbie Question

Status
Not open for further replies.

kar2on

Member level 1
Joined
Jul 30, 2005
Messages
32
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,728
configuration word with mikroc

I recently purchased a JDM PIC programmer, and successfully programed a PIC18f452, or so it seems. When I place the PIC into a test circuit, (blinking LED on portD) nothing happens. The PIC VDD has 5V from a voltage regulator. I really don't know what the problem is, my mikroC program is as follows:-

void main(){

TRISD=0;

while(1){
TRISD=0xFF;
Delay_ms(1000);
TRISD=0X00;
Delay_ms(1000);
}

}

THe ciruit is on a breadboard. Sometimes ALL the pins are high, most of the time ALL the pins are low. What is wrong? The circuit is on a breadboard, and the crystal frequency is 10Mhz. In mikroC I set the clock frequency to 2.5Mhz and HS mode for the crystal oscillator. What could be the problem. It's not the PIC as I've tried this with 3 different PICs. I connect pin 1 to 5V through a 10K Resistor. I'll upload a circuit diagram later but really need help on this. Thanx.

Added after 6 minutes:

while(1){
TRISD=0xFF;
Delay_ms(1000);
TRISD=0X00;
Delay_ms(1000);
}

It should read PORTD=0xFF;
and PORTD = 0x00;
 

Hi karZon,
I am not familiar with your programmer. Can you debug (ssingle step through your programe with your programmer?). Also I am not too clear on what you are trying to do. All your code does is to switch port D from input to output and back. In order to drive a LED you will have to configure that specific bit to output and set it to a known state, either high or low. Also be carefull of the frequency. The LED might be flashing so fast that you will not be able to see it flasshing.

I will try with some more help once you provide the schematic and some info.
Regards.
 

Hi kar2on,

You have to use lower value than 250 in delay routine.

Regrads,
 

why do I need to use a value lower than 250? Before that could I ask could this be done on a breadboard, and if I put a 4Mhz crystal operating at HS mode? would setting the clock to 1Mhz in mikroC be correct?
 

HI,

I can't get the darn thing to work? Has anyone had any experience using mikroC on ICPROG on a JDM programmer? Are there compatibility issues. I suspect something is wrong with teh configuration bytes. It keeps reading in as 2100 even though I'm writing f9ff into the CONFIG1 byte for the oscilattor settings. PLEASE help I really don't know what's wrong, I've gotten simple programs like

PORTB=0x99;
to work, but once i try to blink them the whole just screws up. It's either ALL pins are high or ALL pins are low. CAN SOMEONE help,

I suspect the problem lies in the config file, I've decided to use RCIO oscillator setting,
If i do this, with a 10K resistor and 22pf capacitor then accordingly I should set the frequency in mikroC to 2mHZ right? Like I said simply setting and resetting PORTS are simple, but I can't get the darn thing to blink.

For hardware, I want to use a 4MHZ crystal oscillator connected to 2 22pf capaciators to ground. PIN 1 is connected to 5V via a 10K resistor and pin 11 is connected straight to 5 V. Pin 10 is connected to ground.

5 V is supplied by a 7805 voltage regulator with a 9V battery as input. One 10uf capacitor is connected across the input and ground, and another is connected across the ground and output. Output as an additional 100pf capacitor in parallel.

When I want to use the crystal I select as my FIRST config byte 2900, are there any other config BYTES that need to be set? If I use a 4MHZ crystal is 1mHZ the correct frequency for mikroC?

I set the mikroC program for 1MHZ and i put 3 Delay_ms(200) in between the toggling of ports, the program looks like this.

void main(){
TRISB=0x00;
do{
PORTB=0x00;
Delay_ms(200);
Delay_ms(200);
Delay_ms(200);
PORTB=0xFF;
Delay_ms(200);
Delay_ms(200);
Delay_ms(200);
}while(1);

}

the program compiles fine and the hex code is generated. HOwever like I said the config files are not being correctly loaded to the PIC. I'm worried about this and suspect this to be the problem, it could also be that I'm using a breadboard and not a veraboard or PCB. Please Help.

Added after 55 seconds:

Once again a mistake, PIN 12 is connected to ground and not pin 10. Sorry
 

First hardware:
1 - You have to put +5V on pins 11 and 32, and GND on pins 12 and 32.
2 - Can your battery supply LED current more PIC current?

Software

void main(void)
{
TRISB = 0; //Port B as output
while (1)
{
if (PORTB.F0) // If BIT 0 of PORTB = 1 then
PORTB.F0 = 0;
else
PORTB.F0 = 1;
Vdelay_ms(1000); // Not depend of clock frequency
}
}

About oscillator configuration the wizard can help you configure ...
 

Do you need to connect BOTH VDD pins to 5V?? I thought one was sufficient?
 

You need connect all Vdd and Vss pins.
 

ic ..... I thought only one VDD pin was sufficient, I'll try that configuration tonight. Meanwhile does anybody else have any suggestion as to the source of my problems?
 

Check configuration word, that set to crystal ossillator, then try ro replace crystal ossilator,
 

kar2on said:
HI,

... Has anyone had any experience using mikroC on ICPROG on a JDM programmer? Are there compatibility issues ...

similar topic was in the forum

so it is and instead of icprog use winpic800 it solved my problem also it can detect the PIC automatically !!!

regards
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top