Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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
 
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);
 
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.

Latest threads

New Articles From Microcontroller Tips

Back
Top