Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkpointing #99

Open
wants to merge 2 commits into
base: checkpointing
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions examples/msp430x/small/msp430fr5994/launchpad/fft_lea/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Basic example using LEA to perform fft

This application is a simple example with a variable defined in LEA_SRAM.
To define the appropriate section that is used, with follow the rules given by the AUTOSAR standard, using a symbol definition, followed by the inclusion of a tpl_memmap.h header file.

This approach make the application independant of the linker directives.

The SystemCounter is at 1ms. The serial configuration is 9600, 8N1, with the serial line connected to the debugger (/dev/ttyACM1 on Linux).

`
goil --target=msp430x/small/msp430fr5994/launchpad --templates=../../../../../../goil/templates/ fft_lea.oil
`
101 changes: 101 additions & 0 deletions examples/msp430x/small/msp430fr5994/launchpad/fft_lea/fft_lea.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#include "tpl_os.h"
#include "msp430.h"
#include <math.h>
#include <stdint.h>
#include <stdbool.h>
#include "tpl_clocks.h"

/* Input signal parameters */
#define FS 8192
#define SAMPLES 256
#define SIGNAL_FREQUENCY1 200
#define SIGNAL_AMPLITUDE1 0.6

/* Constants */
#define PI 3.1415926536

#define APP_Task_fft_START_SEC_LEA_VAR_LEA_16BIT
#include "tpl_memmap.h"

VAR(_q15, AUTOMATIC) input[SAMPLES];

#define APP_Task_fft_STOP_SEC_LEA_VAR_LEA_16BIT
#include "tpl_memmap.h"

/* Function prototypes */
extern void initSignal(void);

#define APP_Task_fft_START_SEC_CODE
#include "tpl_memmap.h"


/*----------------------------------------------------------------------------*/
/* main function */
/*----------------------------------------------------------------------------*/
FUNC(int, OS_APPL_CODE) main(void)
{
/* Disable WDT */
WDTCTL = WDTPW + WDTHOLD;

P1DIR |= BIT0 + BIT1;
P1OUT &= ~BIT0;
P1OUT &= ~BIT1;

PM5CTL0 &= ~LOCKLPM5;

tpl_serial_begin();
StartOS(OSDEFAULTAPPMODE);
return 0;
}

void initSignal(void){
msp_status status;
msp_sinusoid_q15_params sinParams;
/* Generate Q15 input signal */
sinParams.length = SAMPLES;
sinParams.amplitude = _Q15(SIGNAL_AMPLITUDE1);
sinParams.cosOmega = _Q15(cosf(2*PI*SIGNAL_FREQUENCY1/FS));
sinParams.sinOmega = _Q15(sinf(2*PI*SIGNAL_FREQUENCY1/FS));
status = msp_sinusoid_q15(&sinParams, input);
msp_checkStatus(status);
}

//#define APP_COMMON_STOP_SEC_CODE
//#include "tpl_memmap.h"

//#define APP_Task_fft_START_SEC_CODE
//#include "tpl_memmap.h"
/*----------------------------------------------------------------------------*/
/* TASK fft */
/*----------------------------------------------------------------------------*/
TASK(fft)
{
P1OUT |= BIT0;
msp_status status;
msp_fft_q15_params fftParams;
int i;

initSignal();

for(i=0; i<SAMPLES; i++){
tpl_serial_print_int(input[i], 0);
tpl_serial_print_string("\n");
}
/* Initialize the fft parameter structure. */
fftParams.length = SAMPLES;
fftParams.bitReverse = true;
fftParams.twiddleTable = MAP_msp_cmplx_twiddle_table_2048_q15;

status = MAP_msp_fft_fixed_q15(&fftParams, input);
msp_checkStatus(status);
for(i=0; i<SAMPLES; i++){
tpl_serial_print_int(input[i], 0);
tpl_serial_print_string("\n");
}
P1OUT |= BIT1;
TerminateTask();
}
#define APP_Task_fft_STOP_SEC_CODE
#include "tpl_memmap.h"


72 changes: 72 additions & 0 deletions examples/msp430x/small/msp430fr5994/launchpad/fft_lea/fft_lea.oil
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
OIL_VERSION = "2.5";

IMPLEMENTATION trampoline {
/* This fix the default STACKSIZE of tasks */
TASK {
UINT32 STACKSIZE = 100 ;
} ;

/* This fix the default STACKSIZE of ISRs */
ISR {
UINT32 STACKSIZE = 100 ;
} ;
};

CPU checkpoint {
OS config {
STATUS = EXTENDED;
PAINT_STACK = TRUE;
PAINT_REGISTERS = TRUE;
CPU_FREQ_MHZ = 8;
IDLE_POWER_MODE = LPM3;
LEA = TRUE {
LEA_RAM = 4096;
};
CHECKPOINTING = FALSE;
BUILD = TRUE {
TRAMPOLINE_BASE_PATH = "../../../../../..";
APP_SRC = "fft_lea.c";
APP_NAME = "fft_lea_exe";
CFLAGS = "-O0 -g3 -gdwarf-2 -ggdb"; //gdb usage
LDFLAGS = "-Map=fft_lea.map";
LIBRARY = dsplib;
LIBRARY = serial {
TXBUFFER = 32;//16;
RXBUFFER = 32;
};
//use either msp-gcc (provided with Energia)..
//CPPCOMPILER = "msp430-g++";
//COMPILER = "msp430-gcc";
//ASSEMBLER = "msp430-gcc";
//LINKER = "msp430-ld";
//COPIER = "msp430-objcopy";
//or GCC for MSP (provided by TI)
CPPCOMPILER = "msp430-elf-g++";
COMPILER = "msp430-elf-gcc";
ASSEMBLER = "msp430-elf-gcc";
LINKER = "msp430-elf-ld";
COPIER = "msp430-elf-objcopy";
//CFLAGS = "-I/opt/ti/msp430-gcc/include";
CFLAGS = "-I /home/user/Source/msp430-gcc-support-files-1.211/msp430-gcc-support-files/include";
SYSTEM = PYTHON;
};
SYSTEM_CALL = TRUE;
MEMMAP = TRUE {
COMPILER = gcc;
LINKER = gnu_ld { SCRIPT = "script.ld"; };
ASSEMBLER = gnu_as;
MEMORY_PROTECTION = FALSE;
};
};

APPMODE std {}; // Warning: std will make a problem iwth the namespace std!

/* TASKS */
TASK fft {
PRIORITY = 3;
AUTOSTART = TRUE {APPMODE = std;};
ACTIVATION = 1;
SCHEDULE = FULL;
};
};

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target remote localhost:2000
delete

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ if exists OS::BUILD_S::LIBRARY then
}
end if
end if
if exists libMap["dsplib"] then
let ISR += @{
SOURCE : "LEA_VECTOR",
CATEGORY : 1,
PRIORITY : 1
}
end if
end if

#------------------------------------------------------------------------------*
Expand Down
33 changes: 33 additions & 0 deletions goil/templates/compiler/gcc/msp430x/MemMap_h.goilTemplate
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,39 @@ foreach proc in PROCESSES do
end foreach
%

/*
* LEA Variables sections
*/
%
foreach SECTION_KIND in @( "_LEA_" ) do
foreach DATA_SIZE in @( "32BIT","16BIT","8BIT","BOOLEAN","UNSPECIFIED" ) do
%
#ifdef APP_% !proc::KIND %_% !proc::NAME %_START_SEC_LEA_VAR% !SECTION_KIND !DATA_SIZE %
#undef APP_% !proc::KIND %_% !proc::NAME %_START_SEC_LEA_VAR% !SECTION_KIND !DATA_SIZE %
#ifdef CURRENT_LINKER_DATA_SECTION
#error "Starting a new % !proc::KIND % % !proc::NAME % lea data section while a section is already started"
#else
#undef MEMMAP_ERROR
#undef CURRENT_LINKER_DATA_SECTION_NAME
#define CURRENT_LINKER_DATA_SECTION_NAME __attribute__ ((section (".% !proc::KIND %_% !proc::NAME %_SEC_LEA_VAR% !SECTION_KIND !DATA_SIZE %")))
#define CURRENT_LINKER_DATA_SECTION
#endif
#endif
#ifdef APP_% !proc::KIND %_% !proc::NAME %_STOP_SEC_LEA_VAR% !SECTION_KIND !DATA_SIZE %
#undef APP_% !proc::KIND %_% !proc::NAME %_STOP_SEC_LEA_VAR% !SECTION_KIND !DATA_SIZE %
#ifdef CURRENT_LINKER_DATA_SECTION
#undef MEMMAP_ERROR
#undef CURRENT_LINKER_DATA_SECTION
#undef CURRENT_LINKER_DATA_SECTION_NAME
#define CURRENT_LINKER_DATA_SECTION_NAME
#else
#error "No section started"
#endif
#endif
%
end foreach
end foreach
%
/*
* Non Volatile Variables sections
*/
Expand Down
6 changes: 5 additions & 1 deletion goil/templates/config/msp430x/config.oil
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ IMPLEMENTATION msp430x {
TRUE {UINT32 CYCLETIME = 5000;},
FALSE
] CHECKPOINTING = FALSE;

/* enable use of LEA and size of LEA RAM */
BOOLEAN [
TRUE {UINT32 LEA_RAM = 4096;},
FALSE {UINT32 LEA_RAM = 0;}
] LEA = FALSE;
/* trace */
BOOLEAN [
TRUE {
Expand Down
113 changes: 112 additions & 1 deletion goil/templates/config/msp430x/small/msp430fr5994/launchpad/config.oil
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ IMPLEMENTATION lauchpad {
},
adc,
ref_a,
checkpointing
checkpointing,
dsplib
] LIBRARY[];
},
FALSE
Expand Down Expand Up @@ -50,4 +51,114 @@ CPU launchpad {
// NEEDS = adc;
// NEEDS = ref_a;
};
LIBRARY dsplib {
PATH = "msp430x/small/msp430fr5994/launchpad/dsplib";
CHEADER = "include/DSPLib.h";
CFILE = "source/filter/msp_biquad_cascade_df1_q15.c";
CFILE = "source/filter/msp_biquad_cascade_df2_ext_q15.c";
CFILE = "source/filter/msp_biquad_cascade_df2_q15.c";
CFILE = "source/filter/msp_biquad_df1_q15.c";
CFILE = "source/filter/msp_biquad_df2_ext_q15.c";
CFILE = "source/filter/msp_biquad_df2_q15.c";
CFILE = "source/filter/msp_cmplx_fir_iq31.c";
CFILE = "source/filter/msp_cmplx_fir_q15.c";
CFILE = "source/filter/msp_fir_q15.c";
CFILE = "source/filter/msp_fir_iq31.c";
CFILE = "source/lea/msp_lea_flags.c";
CFILE = "source/lea/msp_lea_init.c";
CFILE = "source/lea/msp_lea_isr.c";
CFILE = "source/lea/msp_lea_patch.c";
CFILE = "source/matrix/msp_matrix_abs_iq31.c";
CFILE = "source/matrix/msp_matrix_abs_q15.c";
CFILE = "source/matrix/msp_matrix_add_iq31.c";
CFILE = "source/matrix/msp_matrix_add_q15.c";
CFILE = "source/matrix/msp_matrix_mpy_iq31.c";
CFILE = "source/matrix/msp_matrix_mpy_q15.c";
CFILE = "source/matrix/msp_matrix_neg_iq31.c";
CFILE = "source/matrix/msp_matrix_neg_q15.c";
CFILE = "source/matrix/msp_matrix_offset_iq31.c";
CFILE = "source/matrix/msp_matrix_offset_q15.c";
CFILE = "source/matrix/msp_matrix_scale_iq31.c";
CFILE = "source/matrix/msp_matrix_scale_q15.c";
CFILE = "source/matrix/msp_matrix_shift_iq31.c";
CFILE = "source/matrix/msp_matrix_shift_q15.c";
CFILE = "source/matrix/msp_matrix_sub_iq31.c";
CFILE = "source/matrix/msp_matrix_sub_q15.c";
CFILE = "source/matrix/msp_matrix_trans_iq31.c";
CFILE = "source/matrix/msp_matrix_trans_q15.c";
CFILE = "source/transform/msp_cmplx_bitrev_iq31.c";
CFILE = "source/transform/msp_cmplx_bitrev_q15.c";
CFILE = "source/transform/msp_cmplx_fft_auto_q15.c";
CFILE = "source/transform/msp_cmplx_fft_fixed_q15.c";
CFILE = "source/transform/msp_cmplx_fft_iq31.c";
CFILE = "source/transform/msp_cmplx_ifft_auto_q15.c";
CFILE = "source/transform/msp_cmplx_ifft_fixed_q15.c";
CFILE = "source/transform/msp_cmplx_ifft_iq31.c";
CFILE = "source/transform/msp_fft_auto_q15.c";
CFILE = "source/transform/msp_fft_fixed_q15.c";
CFILE = "source/transform/msp_fft_iq31.c";
CFILE = "source/transform/msp_ifft_auto_q15.c";
CFILE = "source/transform/msp_ifft_fixed_q15.c";
CFILE = "source/transform/msp_ifft_iq31.c";
CFILE = "source/transform/msp_split_iq31.c";
CFILE = "source/transform/msp_split_q15.c";
CFILE = "source/transform/msp_transform_tables.c";
CFILE = "source/utility/msp_cmplx_fill_iq31.c";
CFILE = "source/utility/msp_cmplx_fill_q15.c";
CFILE = "source/utility/msp_cmplx_iq31.c";
CFILE = "source/utility/msp_cmplx_q15.c";
CFILE = "source/utility/msp_copy_iq31.c";
CFILE = "source/utility/msp_copy_q15.c";
CFILE = "source/utility/msp_deinterleave_iq31.c";
CFILE = "source/utility/msp_deinterleave_q15.c";
CFILE = "source/utility/msp_fill_iq31.c";
CFILE = "source/utility/msp_fill_q15.c";
CFILE = "source/utility/msp_interleave_iq31.c";
CFILE = "source/utility/msp_interleave_q15.c";
CFILE = "source/utility/msp_iq31_to_q15.c";
CFILE = "source/utility/msp_q15_to_iq31.c";
CFILE = "source/utility/msp_sinusoid_q15.c";
CFILE = "source/vector/msp_abs_iq31.c";
CFILE = "source/vector/msp_abs_q15.c";
CFILE = "source/vector/msp_add_iq31.c";
CFILE = "source/vector/msp_add_q15.c";
CFILE = "source/vector/msp_cmplx_add_iq31.c";
CFILE = "source/vector/msp_cmplx_add_q15.c";
CFILE = "source/vector/msp_cmplx_conj_iq31.c";
CFILE = "source/vector/msp_cmplx_conj_q15.c";
CFILE = "source/vector/msp_cmplx_mac_iq31.c";
CFILE = "source/vector/msp_cmplx_mac_q15.c";
CFILE = "source/vector/msp_cmplx_mpy_iq31.c";
CFILE = "source/vector/msp_cmplx_mpy_q15.c";
CFILE = "source/vector/msp_cmplx_mpy_real_iq31.c";
CFILE = "source/vector/msp_cmplx_mpy_real_q15.c";
CFILE = "source/vector/msp_cmplx_scale_iq31.c";
CFILE = "source/vector/msp_cmplx_scale_q15.c";
CFILE = "source/vector/msp_cmplx_shift_iq31.c";
CFILE = "source/vector/msp_cmplx_shift_q15.c";
CFILE = "source/vector/msp_cmplx_sub_iq31.c";
CFILE = "source/vector/msp_cmplx_sub_q15.c";
CFILE = "source/vector/msp_mac_iq31.c";
CFILE = "source/vector/msp_mac_q15.c";
CFILE = "source/vector/msp_max_iq31.c";
CFILE = "source/vector/msp_max_q15.c";
CFILE = "source/vector/msp_max_uq31.c";
CFILE = "source/vector/msp_max_uq15.c";
CFILE = "source/vector/msp_min_iq31.c";
CFILE = "source/vector/msp_min_q15.c";
CFILE = "source/vector/msp_min_uq31.c";
CFILE = "source/vector/msp_min_uq15.c";
CFILE = "source/vector/msp_mpy_iq31.c";
CFILE = "source/vector/msp_mpy_q15.c";
CFILE = "source/vector/msp_neg_iq31.c";
CFILE = "source/vector/msp_neg_q15.c";
CFILE = "source/vector/msp_offset_iq31.c";
CFILE = "source/vector/msp_offset_q15.c";
CFILE = "source/vector/msp_scale_iq31.c";
CFILE = "source/vector/msp_scale_q15.c";
CFILE = "source/vector/msp_shift_iq31.c";
CFILE = "source/vector/msp_shift_q15.c";
CFILE = "source/vector/msp_sub_iq31.c";
CFILE = "source/vector/msp_sub_q15.c";
};
};
Loading