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.

PIC32 Malloc Error

Status
Not open for further replies.

Sheshebens

New Member
I want to make 3s charger to use Charger 9 click,but When I use Charger 9 click code ı encountered malloc error.I will show you code.I took this code from microelectronica web site. https://www.mikroe.com/charger-9-click**broken link removed** am using microC PRO for PIC32.


void applicationTask()
{
rx_dat = UART_Rdy_Ptr();

if (rx_dat != 0)
{
rx_dat = UART_Rd_Ptr();

switch (rx_dat)
{
case 'e' :
{
if (en_flag == _CHARGER9_DISABLE)
{
charger9_enable( _CHARGER9_ENABLE );
en_flag = _CHARGER9_ENABLE;

mikrobus_logWrite( "** Charger 9 is enabled **", _LOG_LINE );
alarmOn();
}
else
{
mikrobus_logWrite( "** Charger 9 is already enabled **", _LOG_LINE );
}
break;
}
case 'd' :
{
if (en_flag == _CHARGER9_ENABLE)
{
charger9_enable( _CHARGER9_DISABLE );
en_flag = _CHARGER9_DISABLE;

mikrobus_logWrite( "** Charger 9 is disabled **", _LOG_LINE );
alarmOff();
}
else
{
mikrobus_logWrite( "** Charger 9 is already disabled **", _LOG_LINE );
}
break;
}
case 's' :
{
charge_state = charger9_fullChargeInd();

if (charge_state == _CHARGER9_IND_ACTIVE)
{
mikrobus_logWrite( "** Full-Charge state **", _LOG_LINE );
}

charge_state = charger9_fastChargeInd();

if (charge_state == _CHARGER9_IND_ACTIVE)
{
mikrobus_logWrite( "** Fast-Charge state **", _LOG_LINE );
}
break;
}
case 'l' :
{
writeLegend();
break;
}
default :
{
mikrobus_logWrite( "** Invalid command **", _LOG_LINE );
writeLegend();
break;
}
}
}

charge_state = charger9_faultInd();

if (charge_state == _CHARGER9_IND_ACTIVE)
{
charger9_enable( _CHARGER9_DISABLE );
en_flag = _CHARGER9_DISABLE;

mikrobus_logWrite( "** Fault condition! **", _LOG_LINE );
mikrobus_logWrite( "** Charger 9 is disabled **", _LOG_LINE );
alarmFault();
}
}

When I used this code I have some error.
Error name :4622 393 'malloc' Identifier redefined __Lib_dlmalloc.c

I don't have any idea how can ı solve this problem.

How can ı solve this malloc error.
Thanks.
 
Thanks for advice,I am a student,I dont know how can use pic32 vs.I found charger 9 click code but how can I defined microbus_logwrite,What is my referance for microbus_logwrite.

mikrobus_logWrite( "***********************************", _LOG_LINE );
mikrobus_logWrite( "** Commands Legend **", _LOG_LINE );
mikrobus_logWrite( "***********************************", _LOG_LINE );
mikrobus_logWrite( "e - to enable Charger 9", _LOG_LINE );
mikrobus_logWrite( "d - to disable Charger 9", _LOG_LINE );
mikrobus_logWrite( "s - to check charging state", _LOG_LINE );
mikrobus_logWrite( "l - to see commands legend", _LOG_LINE );
mikrobus_logWrite( "***********************************", _LOG_LINE );

For example,this code copied charger 9 click,when ı run code,ı have another error.This error is 'microbus_logwrite'.

What should ı write before the mikrobus_logWrite( "** Commands Legend **", _LOG_LINE );.What shoul ı write instead of command legend.

Thank you.
 
As Ian says, the program you have is just a fragment of an overall program.

What you need is an overall program to initialise the PIC hardware etc. and do all the other things the overall system needs, then add the part to communicate with that charger.

To put it another way, it's a bit like you have a "device driver" file but not the rest of the system to add it in to, so it cannot do anything.
 
I tried initalise the PIC32 pıns what you need.My code look like,

mikrobus_logWrite( RB4(what command is say to me ,ı looked pıc32 pın number or pın numbers value afterthat ı wrote), _LOG_LINE );

but it not acceptable,Again ı have the same error.
 
Many parts of that program fragment are dependant on other software, which you do not have.

Both the "Charger click 9" module and the program fragment are designed as add-ons for Microe development boards such as this:

You need the rest of the program for that board and adapt it to your hardware, then you may be able to add the charger hardware and software, with appropriate modifications.
 
When I use PIC18, these codes doesn't have any problem for charger 9 click code , I downloaded package manager and use suitable program for which was downloanded package manager. I ınstalled and build charger 9 click, I dont have any problem,because PIC18 libraries has speciaI three sublibraries for PIC18 developmant card. I thought PIC32 libraries missing. We need Three sublibraries same like PIC18 sublibraries. What do you think?

I will show you PIC18 libraries png.

Ekran görüntüsü 2021-07-27 113551.png

I need the same library for PIC32 like easypicpro.... or something.I do not have microbus_gpioInıt, microbus_logInıt, microbus_logWrite.

Thank you.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top