Load hex via mplab

General discussion on mikroC.
Post Reply
Author
Message
prancius
Posts: 148
Joined: 26 Sep 2007 21:52

Load hex via mplab

#1 Post by prancius » 14 Oct 2011 22:03

Hello,

I want to write source with mikroc and load hex file to device via MPLAB. But something i am doing wrong.

Code: Select all

void main() 
{

  TRISB=0;
  PORTB=0;
  
  for(;;)
  {
   PORTB.F4=~PORTB.F4;
   Delay_ms(500);
  }

}

I have checked configuration bits its looks ok.
What else could be whe problem. Led is not blinking.

Image
Image

Regards,
Pranas

p.erasmus
Posts: 3391
Joined: 05 Mar 2009 10:28

Re: Load hex via mplab

#2 Post by p.erasmus » 14 Oct 2011 22:18

Use LATB.B4 and not PORT for PIC18 because of RWM effects see compiler help file

try this to toggle LED

Code: Select all


LATB.B4 ^=1;
P.Erasmus
Saratov,Russia
--------------------------------------------------------------

prancius
Posts: 148
Joined: 26 Sep 2007 21:52

Re: Load hex via mplab

#3 Post by prancius » 15 Oct 2011 17:05

Code: Select all

void main() 
{

  TRISB=0;
  LATB=0;
  
  for(;;)
  {
   LATB.B4=~LATB.B4;
   Delay_ms(500);
  }

}

No the problem is not here


p.erasmus
Posts: 3391
Joined: 05 Mar 2009 10:28

Re: Load hex via mplab

#4 Post by p.erasmus » 15 Oct 2011 17:13

You can not do as ypu did it
I showed you the correct way

anycase to write to pins use LAT to read pins use PORT see below

Code: Select all


 for(;;)
  {
   LATB.B4=~PORTB.B4;
   Delay_ms(500);
  }
read the manual as I advised !!
P.Erasmus
Saratov,Russia
--------------------------------------------------------------

prancius
Posts: 148
Joined: 26 Sep 2007 21:52

Re: Load hex via mplab

#5 Post by prancius » 15 Oct 2011 18:09

tried, not the problem. Something between mikroc and mplab

prancius
Posts: 148
Joined: 26 Sep 2007 21:52

Re: Load hex via mplab

#6 Post by prancius » 17 Oct 2011 07:26

Also checked hex file size.
With microc it is 325 bytes

Code: Select all

void main() 
{

  TRISB=0;
  PORTB=0;
  
  for(;;)
  {
   LATB.B4=~PORTB.B4;
   Delay_ms(500);
  }

}
With mplab C18 hex file size is 956 bytes (it is 3x times more)

Code: Select all

#include "p18f67j60.h"
#include "delays.h"

void main (void)
{

	TRISB = 0b00000000; 
                 PORTB = 0b00000000;

	while (1)
	{

		PORTB=~PORTB;
		Delay1KTCYx(2);
	
	}
	
}

Maybe there is some stranges?

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Load hex via mplab

#7 Post by filip » 17 Oct 2011 10:55

Hi,

This seems to be an issue with the oscillator.
As I can see from the Edit Project windows, you have selected ECPLL External Clock with Software PLL Control.

I have tried this on LV18F v6 with MCU card which has no external clock and none of the LEDs flashed.

As soon as I have switched to HS, everything worked OK.

Regards,
Filip.

prancius
Posts: 148
Joined: 26 Sep 2007 21:52

Re: Load hex via mplab

#8 Post by prancius » 17 Oct 2011 18:53

Thank you.

You solved the problem.

Post Reply

Return to “mikroC General”