Part Number:MSP430G2553
Tool/software: Code Composer Studio
This article describes how to use the Malloc and the Calloc in small memory microcontrollers like the MSP430. Unlike many YouTube videos where they show this utility using higher memory chips and PCs, this one, specifically concentrates on using and demonstrating the same on low scale memory MSP430G2xx series. I have uploaded a simple video in YouTube that describes and shows very simply how you can allocate in the value line series MCUs.
I don't know how many people actually need to use malloc , calloc, realloc and free in MSP430, but if you choose to do, this video link can be of help to such users.
The code is here:
#include <msp430.h>
#include <stdlib.h>
/**
* blink.c
*/
void main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
P1DIR |= 0x01; // configure P1.0 as output
volatile unsigned int i; // volatile to prevent optimization
int *p = (int*)malloc(5*sizeof (int));
// p[0] = 1;
// p[1] = 2;
// p[2] = 3;
// free(p);
int *pt = (int*)calloc(5,sizeof (int));
pt[0] = 10;
pt[1] = 20;
pt[2] = 30;
while(1)
{
P1OUT ^= 0x01; // toggle P1.0
for(i=10000; i>0; i--); // delay
}
}
BELOW IS YOUTUBE LINK TO THE VIDEO:
(Please visit the site to view this video)
If you want more such libraries that I have developed for MSP430x2xx and MSP430x5xx series please visit : http://www.turjasuzworld.in/msp430x2xx-libraries-for-ccs/