필터 지우기
필터 지우기

Embedded program hangs because UART transmission

조회 수: 4 (최근 30일)
Alberto Prudhomme
Alberto Prudhomme 2016년 10월 4일
편집: Alberto Prudhomme 2016년 10월 4일
Hi,
I have a problem with my embedded programming with TivaC launchpad. I have a lot of blocks that include I2C acquisition for an IMU, a UART for GPS and a UART for Xbee.
The last part of the program that I made was the Xbee transmission. Before I made the Xbee block all the program runs perfectly in my launch pad, but when I made the S-function for the serial transmission I found 2 problems.
First: When I begin the program all run fine for 5-6 seconds, but sometimes it can run for 2 minutes without a problem, but in some moment the program hangs.
Second: I have an ADC input from sonar, when I test and graph without the Xbee the signal are totally plain, but when I test with Xbee sending every 3 seconds the signal from the sonar measure with a pic every time the serial was sent.
I think that with this both errors the problem is the memory managing of the launchpad, but I can't find the way to test or solve it.
This is the code of the S-function for the xbee:
/*
* 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]);
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 */
}
The simulink diagram of the uart section:
Do you have some idea to solve it?
Thanks

답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by