Hello;
I'm making a program in Simulink where I use a TivaC to send information by Serial4, but the problem is that the program runs fine for a little seconds, then the program crash. During the little time that the program runs the variables that don't have any relation with the UART 4 begins to change of values in erratic way.
I tried changing to the port 0, and the program works perfect.
This is the code in the s-function for the serial transmit:
/* * Include Files * */ #if defined(MATLAB_MEX_FILE) #include "tmwtypes.h" #include "simstruc_types.h" #else #include "rtwtypes.h" #endif /* %%%-SFUNWIZ_wrapper_includes_Changes_BEGIN --- EDIT HERE TO _END */ # ifndef MATLAB_MEX_FILE # include <Energia.h> # include <math.h> # endif /* %%%-SFUNWIZ_wrapper_includes_Changes_END --- EDIT HERE TO _BEGIN */ /* * Create external references here. * */ /* %%%-SFUNWIZ_wrapper_externs_Changes_BEGIN --- EDIT HERE TO _END */ /* extern double func(double a); */ /* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */ /* * Output functions * */ extern "C" void Radio_Link_Outputs_wrapper(const real_T *UART_1, const real_T *xD, const int_T u_width) { /* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */ if (xD[0] == 1){ # ifndef MATLAB_MEX_FILE int as=0; Serial4.print('$'); for (as=0;as<u_width;as=as+1){ Serial4.print(UART_1[as],6); if (as!=(u_width-1)){ Serial4.print(','); } } Serial4.println('%'); # endif } /* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */ } /* * Updates function * */ extern "C" void Radio_Link_Update_wrapper(const real_T *UART_1, real_T *xD, const int_T u_width) { /* %%%-SFUNWIZ_wrapper_Update_Changes_BEGIN --- EDIT HERE TO _END */ if (xD[0] != 1){ # ifndef MATLAB_MEX_FILE Serial4.begin(57600); # endif xD[0] = 1; } /* %%%-SFUNWIZ_wrapper_Update_Changes_END --- EDIT HERE TO _BEGIN */ }
Do you have some idea of why the problem appears in other port less the port 0??
Thanks
Alberto