This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/MSP430F5529: CCS/MSP430F5529

Part Number: MSP430F5529
Other Parts Discussed in Thread: MSP430WARE, SYSBIOS

Tool/software: Code Composer Studio

Hi,

I just build a project in Code Composer Studio Version 6.1.2.00015. I am using MSP430F5529LP as my target device. My console after I build my project is something like this:

'Building target: T2Project_3.out'
'Invoking: MSP430 Linker'
"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.5/bin/cl430" -vmspx --abi=eabi --data_model=restricted --use_hw_mpy=F5 --advice:power_severity=suppress --advice:hw_config="1" -g --define=__MSP430F5529__ --define=ccs --define=MSP430WARE --diag_warning=225 --diag_warning=255 --diag_wrap=off --display_error_number --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU23 --silicon_errata=CPU40 --printf_support=minimal -z -m"T2Project_3.map" --heap_size=160 --stack_size=160 --cinit_hold_wdt=on -i"C:/ti/ccsv6/ccs_base/msp430/include" -i"C:/ti/ccsv6/ccs_base/msp430/lib/5xx_6xx_FRxx" -i"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.5/lib" -i"C:/ti/ccsv6/tools/compiler/ti-cgt-msp430_4.4.5/include" --reread_libs --warn_sections --diag_wrap=off --display_error_number --xml_link_info="T2Project_3_linkInfo.xml" --use_hw_mpy=F5 --rom_model -o "T2Project_3.out" "./MSP_EXP430F5529LP.obj" "./T3.obj" "./mlifo3.obj" "../MSP_EXP430F5529LP.cmd" -l"configPkg/linker.cmd" -l"libmath.a" -l"C:/ti/tirtos_msp43x_2_16_00_08/products/msp430_driverlib_2_21_00_08a/driverlib/MSP430F5xx_6xx/ccs/MSP430F5529.lib" -l"libc.a"
<Linking>
warning #10420-D: For FRAM devices, at start up, the GPO power-on default high-impedance mode needs to be disabled to activate previously configured port settings. This can be done by clearing the LOCKLPM5 bit in PM5CTL0 register.
'Finished building target: T2Project_3.out'
' '

**** Build Finished ****

After this step, I debug my project and the result of debug is mentioned below:

**** Build of configuration Debug for project T2Project_3 ****

"C:\\ti\\ccsv6\\utils\\bin\\gmake" -k all
making ../src/sysbios/sysbios.ae430X ...
gmake[1]: Entering directory `C:/Users/Kaustubh/Downloads/T2Project_3/src/sysbios'
gmake[1]: Nothing to be done for `all'.
gmake[1]: Leaving directory `C:/Users/Kaustubh/Downloads/T2Project_3/src/sysbios'

**** Build Finished ****.

The problem is when I click on the run icon I am not able to see anything on my screen except:

The code(some number) and data(bytes) were written to FLASH/FRAM .

I am not able to see my output on the console. Can you please let me know where can be the error in my code .

PLease find below my code. This is my main.c. I have two other files also please have a look at them also and suggest if I am doing something wrong.

#include "mlifo2.h"


#include <xdc/std.h>
#include <xdc/runtime/System.h>

/* BIOS module Headers */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Clock.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <ti/sysbios/knl/Swi.h>
/* Example/Board Header files */
#include "Board.h"

typedef int token_t;
int status;

#define TOKEN_SIZE (sizeof(token_t))
#define MLIFO_CAPACITY 10

#define TASKSTACKSIZE 512
#define MAX_PRODUCER_ITERATION_COUNT 100
uint8_t mlifo_memory[TOKEN_SIZE * MLIFO_CAPACITY];
Task_Struct producerStruct, consumer1Struct, consumer2Struct;
Char producerStack[TASKSTACKSIZE], consumer1Stack[TASKSTACKSIZE], consumer2Stack[TASKSTACKSIZE];


disps_mlifo_pointer mlifo_ctx;

Void clkProducerFxn(UArg arg0);
Void clkConsumer1Fxn(UArg arg0);
Void clkConsumer2Fxn(UArg arg0);

Clock_Struct clkProducerStruct, clkConsumer1Struct, clkConsumer2Struct;


Swi_Struct swiProducerStruct, swiConsumer1Struct, swiConsumer2Struct;
Swi_Handle swiProducerHandle, swiConsumer1Handle, swiConsumer2Handle;


#define A 214013
#define C 2531011
#define M 2

int generate_random_number()
{
static int seed = 0;
//formula for LCG referred from tfetimes.com/.../
seed = (A * seed + C) % M;
return (2 + 2 * seed) ;
}


Void producerFxn(UArg arg0, UArg arg1)
{
static tokenvalue =1;
static int finishCount = 0;

for (;;) {
int N = generate_random_number();
int num_writes = 0;
for (; N > 0; N--) {
if (disps_mlifo_write(mlifo_ctx, &tokenvalue) == 1)
num_writes++;
}
System_printf("%d tokens are written in the buffer.\n", num_writes);

if (status == 0) {
System_printf("Error: mlifo overflow\n");
BIOS_exit(0);
}

finishCount++;
if (finishCount == MAX_PRODUCER_ITERATION_COUNT) {
System_printf("Test complete without underflow/overflow\n");
BIOS_exit(0);
}
}
}


Void consumerFxn(UArg arg0, UArg arg1)
{
token_t token = 0;
int status = disps_mlifo_read(mlifo_ctx, &token);

/* Print appropriate message indicating how many tokens are read from the MLIFO (0 or 1 token). */
System_printf("%d tokens (value = %d) are read from the buffer by taskID %d.\n",1 , 0 );

if (status == 0) {
System_printf("Error: mlifo underflow\n");
BIOS_exit(0);
}

}


Void swiProducerFxn(UArg arg0, UArg arg1)
{
Task_Params taskParams;
Task_Params_init(&taskParams);
taskParams.stackSize = TASKSTACKSIZE;

taskParams.stack = &producerStack;
taskParams.priority = 1;
Task_construct(&producerStruct, (Task_FuncPtr)producerFxn, &taskParams, NULL);


}

/*
* ======== swi1Fxn =======
*/
Void swiConsumer2Fxn(UArg arg0, UArg arg1)
{
Task_Params taskParams;
Task_Params_init(&taskParams);
taskParams.stackSize = TASKSTACKSIZE;


taskParams.stack = &consumer2Stack;
taskParams.priority = 2;
Task_construct(&consumer2Struct, (Task_FuncPtr)consumerFxn, &taskParams, NULL);
}

/*
* ======== swi1Fxn =======
*/
Void swiConsumer1Fxn(UArg arg0, UArg arg1)
{
Task_Params taskParams;
Task_Params_init(&taskParams);
taskParams.stackSize = TASKSTACKSIZE;

taskParams.stack = &consumer1Stack;
taskParams.priority = 2;
Task_construct(&consumer1Struct, (Task_FuncPtr)consumerFxn, &taskParams, NULL);
}

/*
* ======== clk0Fxn =======
*/
Void clkProducerFxn(UArg arg0)
{
Swi_post(swiProducerHandle);
}

Void clkConsumer1Fxn(UArg arg0)
{
Swi_post(swiConsumer1Handle);
}

Void clkConsumer2Fxn(UArg arg0)
{
Swi_post(swiConsumer2Handle);
}

Int main ()
{
Task_Params taskParams;
Swi_Params swiParams;
Clock_Params clkParams;

Board_initGeneral();

mlifo_ctx = disps_mlifo_new(MLIFO_CAPACITY, TOKEN_SIZE, (void *)mlifo_memory);
if (mlifo_ctx == NULL) {
System_printf ("Error(%d): mlifo_ctx is null\n", __LINE__);
return -1;
}
Task_Params_init(&taskParams);


Clock_Params_init(&clkParams);
clkParams.period = 150000;
clkParams.startFlag = TRUE;
Clock_construct(&clkProducerStruct, (Clock_FuncPtr)clkProducerFxn, 5, &clkParams);


clkParams.period = 100000;
clkParams.startFlag = TRUE;
Clock_construct(&clkConsumer1Struct, (Clock_FuncPtr)clkConsumer1Fxn, 10 + 300000, &clkParams);

clkParams.period = 100000;
clkParams.startFlag = TRUE;
Clock_construct(&clkConsumer2Struct, (Clock_FuncPtr)clkConsumer2Fxn, 10 + 300000, &clkParams);

Swi_Params_init(&swiParams);
swiParams.arg0 = 1;
swiParams.arg1 = 0;
swiParams.priority = 2;
swiParams.trigger = 0;

Swi_construct(&swiProducerStruct, (Swi_FuncPtr)swiProducerFxn, &swiParams, NULL);
swiProducerHandle = Swi_handle(&swiProducerStruct);
Swi_construct(&swiConsumer1Struct, (Swi_FuncPtr)swiConsumer1Fxn, &swiParams, NULL);
swiConsumer1Handle = Swi_handle(&swiConsumer1Struct);

Swi_construct(&swiConsumer2Struct, (Swi_FuncPtr)swiConsumer2Fxn, &swiParams, NULL);
swiConsumer2Handle = Swi_handle(&swiConsumer2Struct);


BIOS_start(); /* Does not return */
return(0);
}

2) mlifo.c

#include "mlifo2.h"
disps_mlifo_pointer disps_mlifo_new(int capacity, int token_size, void *mlifo_memory)
{
Semaphore_Params sem_params;
disps_mlifo_pointer mlifo;

if (capacity <= 0)
return NULL;
if (token_size <= 0)
return NULL;
if (mlifo_memory == NULL)
return NULL;

mlifo = (disps_mlifo_pointer) malloc (sizeof (disps_mlifo_type));
mlifo->capacity = capacity;
mlifo->token_size = token_size;
mlifo->mlifo_base_ptr = mlifo_memory;
mlifo->current_size = 0;

Semaphore_Params_init(&sem_params);
Semaphore_construct(&mlifo->sem_struct, 1, &sem_params);
mlifo->sem_handle = Semaphore_handle(&mlifo->sem_struct);

return mlifo;
}

int disps_mlifo_read(disps_mlifo_pointer mlifo, void *data)
{
Semaphore_pend(mlifo->sem_handle, BIOS_WAIT_FOREVER);
if (mlifo->current_size == 0) {
Semaphore_Handle(sem_handle);
return 0;
}

mlifo->current_size--;
memcpy(data, mlifo->mlifo_base_ptr + mlifo->token_size * mlifo->current_size, mlifo->token_size);
Semaphore_Handle(sem_handle);
return 1;
}

int disps_mlifo_write(disps_mlifo_pointer mlifo, void *data)
{
Semaphore_pend(mlifo->sem_handle, BIOS_WAIT_FOREVER);
if (mlifo->current_size == mlifo->capacity) {
Semaphore_Handle(sem_handle);
return 0;
}

memcpy(mlifo->mlifo_base_ptr + mlifo->token_size * mlifo->current_size, data, mlifo->token_size);
mlifo->current_size++;
Semaphore_Handle(sem_handle);
return 1;
}

int disps_mlifo_population(disps_mlifo_pointer mlifo)
{
int size;
Semaphore_pend(mlifo->sem_handle, BIOS_WAIT_FOREVER);
size = mlifo->current_size;
Semaphore_Handle(sem_handle);
return size;
}

3)mlifo.h

mlifo.h
*
* Created on: Jun 21, 2016
* Author: George Zaki
*/

#ifndef MLIFO_H_
#define MLIFO_H_

#include <ti/sysbios/knl/Semaphore.h>
#include <stdlib.h>
#include <ti/sysbios/BIOS.h>


/* A MLIFO. */
typedef struct _disps_mlifo_struct disps_mlifo_type;

/* A pointer to a mlifo. */
typedef disps_mlifo_type *disps_mlifo_pointer;

struct _disps_mlifo_struct {
/* TODO: Add the context definition.*/
int capacity;
int token_size;
uint8_t *mlifo_base_ptr;
int current_size;
Semaphore_Struct sem_struct;
Semaphore_Handle sem_handle;
};

/*****************************************************************************
Create a new MLIFO with the specified capacity (maximum number of tokens that
it can hold), and the specified token_size (the number of bytes used to store a
single token). If the specified capacity is less than or equal to zero, the
specified token size is less than or equal to zero, the function fails silently
and returns NULL.

IMPORTANT NOTE: this function should NOT allocate the memory that will hold the tokens,
instead it should receive a pointer to this memory as an input argument.
*****************************************************************************/
disps_mlifo_pointer disps_mlifo_new(int capacity, int token_size, void *mlifo_memory);

/*****************************************************************************
Read a token from the buffer, and remove the token from the buffer. It is
assumed that the data argument points to a block of memory that consists of at
least N contiguous bytes, where N is the token size associated with the MLIFO.
The function copies N bytes of memory from the current read position in the
MLIFO (the earliest token) into the block of memory pointed to by the data
argument.

TODO: Think about how the function should behave (or return) if the MLIFO
is empty upon entry to this function.
*****************************************************************************/

/** Returns 1 on successful read, 0 on failure. */
int disps_mlifo_read(disps_mlifo_pointer mlifo, void *data);

/*****************************************************************************
Insert a new token into the buffer. This function copies N bytes, where N is
the mlifo token size, starting at the address specified by the data argument.
This data is copied into the next available position in the buffer.

TODO: Think aobu how the function should behave (or return) if the MLIFO
is already full upon entry to this function,
*****************************************************************************/
/** Returns 1 on successful write, 0 on failure. */
int disps_mlifo_write(disps_mlifo_pointer mlifo, void *data);

/*****************************************************************************
Return the number of tokens that are currently in the mlifo.
*****************************************************************************/
int disps_mlifo_population(disps_mlifo_pointer mlifo);

#endif /* MLIFO_H_ */

Help would be highly appreciated.

Thanks

Best,

Reshi Razdan