This is my first program in KDS. I was adding functionalities in Processor Expert, but, after adding the serial communication components, I can no longer add lines of code.
/* ###################################################################
** Filename : main.c
** Project : teste ADC
** Processor : MKE04Z8VFK4
** Version : Driver 01.01
** Compiler : GNU C Compiler
** Date/Time : 2017-03-16, 10:52, # CodeGen: 0
** Abstract :
** Main module.
** This module contains user's application code.
** Settings :
** Contents :
** No public methods
**
** ###################################################################*/
/*!
** @file main.c
** @version 01.01
** @brief
** Main module.
** This module contains user's application code.
*/
/*!
** @addtogroup main_module main module documentation
** @{
*/
/* MODULE main */
/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "Events.h"
#include "AD1.h"
#include "AdcLdd1.h"
#include "TI1.h"
#include "TimerIntLdd1.h"
#include "TU1.h"
#include "LED1.h"
#include "BitIoLdd1.h"
#include "LED2.h"
#include "BitIoLdd2.h"
#include "LED3.h"
#include "BitIoLdd3.h"
#include "LED4.h"
#include "BitIoLdd4.h"
#include "pnCargaCalda.h"
#include "BitIoLdd5.h"
#include "AS1.h"
#include "ASerialLdd1.h"
/* Including shared modules, which are used for whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"
/* User includes (#include below this line is not maintained by Processor Expert) */
unsigned int nrCountTmr100ms = 0;
byte idMeasure, idGetVal;
bool idReadyADC = FALSE;
word vlAdcAlta[4], vlAdcBaixa[4];
unsigned int nrTempoLed[4] = {0x40,0x40,0x40,0x40};
unsigned int nrContTempoLED[4];
unsigned char nrCountTempNivel[4] = {0x0,0x0,0x0,0x0};
unsigned char idNivelCalda[4] = {0x0,0x0,0x0,0x0};
byte idSendMsg = 0;
bool idTmr1 = FALSE;
bool idLeituraAlta = FALSE; // Indica que a leitura de níveis será feita com 5 V aplicado na calda.
/*lint -save -e970 Disable MISRA rule (6.3) checking. */
int main(void)
/*lint -restore Enable MISRA rule (6.3) checking. */
{
/* Write your local variable definition here */
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
PE_low_level_init();
/*** End of Processor Expert internal initialization. ***/
/* Write your code here */
for(;;){
if (idTmr1){
idTmr1 = FALSE;
if (idNivelCalda[0]){
if (++nrContTempoLED[0] >= nrTempoLed[0]){
LED1_NegVal();
nrContTempoLED[0] = 0;
}
} else {
LED1_SetVal();
}
if (idNivelCalda[1]){
if (++nrContTempoLED[1] >= nrTempoLed[1]){
LED2_NegVal();
nrContTempoLED[1] = 0;
}
} else {
LED2_SetVal();
}
if (idNivelCalda[2]){
if (++nrContTempoLED[2] >= nrTempoLed[2]){
LED3_NegVal();
nrContTempoLED[2] = 0;
}
} else {
LED3_SetVal();
}
if (idNivelCalda[3]){
if (++nrContTempoLED[3] >= nrTempoLed[3]){
LED4_NegVal();
nrContTempoLED[3] = 0;
}
} else {
LED4_SetVal();
}
}
if (nrCountTmr100ms >= 100){
nrCountTmr100ms = 0;
if (idLeituraAlta){
pnCargaCalda_SetVal();
} else {
pnCargaCalda_ClrVal();
}
idMeasure = AD1_Measure(FALSE);
}
if (idReadyADC){
if (idLeituraAlta){
idGetVal = AD1_GetValue16(vlAdcAlta);
} else {
idGetVal = AD1_GetValue16(vlAdcBaixa);
}
idLeituraAlta = !idLeituraAlta;
idReadyADC = FALSE;
/*
for (int i = 0; i <= 3; i++){
nrTempoLed[i] = (vlAdcAlta[i] / 20) / 10;
}
*/
}
if (idGetVal == 0x00U){
for (int i = 0; i <= 3; i++){
//AS1_SendChar(0x02);
if (vlAdcAlta[i] > vlAdcBaixa[i]+20){
if (++nrCountTempNivel[i] >= 20){
idNivelCalda[i] = 1;
nrCountTempNivel[i] = 10;
}
} else {
if (--nrCountTempNivel[i] <= 0){
idNivelCalda[i] = 0;
nrCountTempNivel[i] = 10;
}
}
}
idGetVal = 0xFF;
}
}
/*** Don't write any code pass this line, or it will be deleted during code generation. ***/
/*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
#ifdef PEX_RTOS_START
PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of RTOS startup code. ***/
/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
for(;;){}
/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
/* END main */
/*!
** @}
*/
/*
** ###################################################################
**
** This file was created by Processor Expert 10.5 [05.21]
** for the Freescale Kinetis series of microcontrollers.
**
** ###################################################################
*/
If I uncomment the line 145 of the code above, I get this error messages:
This is the image of my PE with the components added. Note that in the console window, the size of program with the line 145 commented.
My program really this big? Did I do something wrong? that caused this problem?
thanks in advance for your time
Original Attachment has been moved to: teste-ADC.zip