MikroPascal default library on P-Star 25K50

Discuss with MikroElektronika software developers about current library development.
Post Reply
Author
Message
loru
Posts: 5
Joined: 29 Apr 2014 07:43

MikroPascal default library on P-Star 25K50

#1 Post by loru » 08 Mar 2016 09:28

Hello to everybody,

I’ve recently bought a couple of P-Star 25k50 by Pololu to use in one of my project. I usually use MikroPascal to compile the hex file because of its libraries! It happens that if I write a simple program to turn on a led without using the MikroPascal internal library, it works fine: I compile the program then I load it into the P-star with its bootloader (I have to use a simple tool called P-load to load the hex into the pic through usb cable) the pic restart and the program runs properly. To correctly program the pic the program has to start from address 0x2000 because of the bootloader which uses the first 8 kb of memory. Here is the simple code that works:

Code: Select all

program library_test_1;

{ Declarations section }

begin
org 0x2000;

ANSELB.3 := 0;
TRISB.3 := 1;

ANSELC.6 := 0;
TRISC.6 := 0;
LATC.6 := 1;  //led on RC6 is off while the pin is high and on while the pin is low

while true do
begin
if (PORTB.3 = 1) then //pin RB3 is pulled-down on GND
begin
LATC.6 := 0;
delay_ms(1000);
LATC.6 := 1;
end
else LATC.6 := 1;
end;
end.
To eliminate the debouncing of the button I'd like to use the button library so I checked Button library, used Button function then compiled this new version of the program. The p-load correctly loads the program into the PIC but suddenly the P-Star restarts to bootloader mode like there is no program inside the pic! (P-Star start in bootloader mode in two case: pin RB6 is high when the pic is turned on or if there is no program in the flash). This is the “library” version of the program:

Code: Select all

program library_test_1;

{ Declarations section }

begin
org 0x2000;

ANSELB.3 := 0;
TRISB.3 := 1;

ANSELC.6 := 0;
TRISC.6 := 0;
LATC.6 := 1;

while true do
begin
if (Button(PORTB, 3, 1, 1)) then
begin
LATC.6 := 0;
delay_ms(1000);
LATC.6 := 1;
end
else LATC.6 := 1;
end;
end.
So, this is my question. Does anyone know if the compiler start to write the program from different addresses if I use or I do not use functions from library in the project?

I am sorry but I am not able to solve this problem; any help or solving direction from you would be really appreciated.

Thank you in advance for your help.

User avatar
biljana.nedeljkovic
mikroElektronika team
Posts: 1043
Joined: 30 Jun 2015 15:15

Re: MikroPascal default library on P-Star 25K50

#2 Post by biljana.nedeljkovic » 08 Mar 2016 10:38

Hello,

I am sorry but it would be great if you would explain more, how does your project and hardware behaves?

Take a look at our Button example to see how to manage debouncing :
"C:\Users\Public\Documents\Mikroelektronika\mikroPascal PRO for PIC\Examples\Development Systems\EASYPIC7\Button"

Kind regards,
Biljana

loru
Posts: 5
Joined: 29 Apr 2014 07:43

Re: MikroPascal default library on P-Star 25K50

#3 Post by loru » 08 Mar 2016 10:55

Hello Biljana,

thank you a lot for your answer. Please believe me, I am not new about programming, I know your library and I used a lot of times function from your libraries. I usually use an easypic v7 to program pic but in this case I have to use the P-star from pololu. I have just asked to them about this problem but they said that all is ok and that program should work. They say: ask to mikroE because maybe the problem is caused by compiler. The program that i need to write is more complicate and i need to use many of your libraries but first i have to check with a simple program that libraries can works!

thank you in advance.

P.S. Do you think that i should to erase the bootloader to solve the problem?

Post Reply

Return to “Library Development Discussion”