pic18f4520 CAUTION

Status
Not open for further replies.

lakis

New Member
Orders #630900
Hi guys i recently bought pic p40 Dev. Board . Although it is simple board when I try to program it with a simple led program I get following .(I am using icd3 c18 library and pic18f4520 or pic18f452)
Target Detected
CAUTION: Check that the device selected in MPLAB IDE (pic18f4520)
is the same one that is physically attached to the debug
tool. Selecting a 5V device when a 3.3V device is connected
can result in damage to the device when the debugger checks
the device ID.
Yes or No
If you chose yes
Program completed
Reading competed
Verify completed
but the leds does not lighting.
This is my program the datasheet of the dev board is the attached file .
Code:
#include<p18f4520.h>
 #pragma config XINST = OFF 
#pragma config LVP=OFF
#pragma config OSC=HS
#pragma config WDT=OFF// Use internal Oscillator, Watchdog off, LVP off
#pragma config MCLRE = ON                    // Extended instruction set on
                  

 
    
void delay (void)
{
  int i;

  for (i = 0; i < 10000; i++)
    ;
}

void main (void)
{
  /* Make all bits on the Port B (LEDs) output bits.
   * If bit is cleared, then the bit is an output bit.
   */
  TRISD = 0;
  while (1)
    {
      /* Reset the LEDs */
      PORTD = 0;

      /* Delay so human eye can see change */
      delay ();

      /* Light the LEDs */
      PORTD= 0x5A;

      /* Delay so human eye can see change */
      delay ();
    }
}
Please help I am desperate.
 
Your oscillator type pragma is incorrect.

OSC=HS is for a high speed external crystal oscillator. For the internal oscillator, change it to OSC=INTIO67. This will give you the INTernal oscillator with IO function on RA6 and RA7.
 
Last edited:
thank you for your answer and i will changed .
But i don't thing that that is reason i have the caution proplem
 
That board has a 20MHz Xtal connected to the 4520.. So the Pragma's are OK.

Is the power Jumper on or Off... The PDF shows 5V operation... If the link is shorted... its 3.3V.
 
Is the pic an LF series? It doesn't matter if it is or not... The LF may not run at 20MHz


Also the delay is only 2mS.... doubt if you would see anything..

Include the delay library
Code:
#include<delays.h>

and use half second delay.
Code:
Delay100KTCYx(9);
 
Like I said 20,000,000Mhz... equates to 200nS per clock cycle... 200nS * 10000 = @2mS... Not enough time to illuminate the LED (for the human eye).
 
Last edited:
Not if its a 5V device fitted... 5V devices will brown out at 4.2V (If BOR is on)

Change the delay to 1/2 a second just to see.
 
Hi,

Have got my 4520 dev board running in front of me, so I have just made this 1 second flasher for PortD,0
It uses the internal oscillator so will just ignore your external.

Have only posted the .hex code as I don't use C.

If you want to send your .hex code back I could try it on my dev board ( not an Olimex)
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…