我正在使用YRDKRL78 G13板。我正在使用IAR v.2.20进行编译,并且已经在其上创建了一个C ++项目。我正在使用一个框架。无论如何,我已经实现了我的所有代码并且工作正常但是在2分钟后,IAR提供的信息为“应用程序已中止”和“程序退出已到达”。我真的很困惑,我用非常大的堆栈作为512而接近1024就是4096.
这是我的main.cpp
#include "System.h"
extern "C"
{
#include "r_cg_macrodriver.h"
}
#pragma location = "OPTBYTE"
__root const uint8_t opbyte0 = 0x7EU;
#pragma location = "OPTBYTE"
__root const uint8_t opbyte1 = 0xFFU;
#pragma location = "OPTBYTE"
__root const uint8_t opbyte2 = 0xE8U;
#pragma location = "OPTBYTE"
__root const uint8_t opbyte3 = 0x85U;
/* Set security ID */
#pragma location = "SECUID"
__root const uint8_t secuid[10] =
{0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U};
void main(void)
{
System::SystemInstance().SYS_vInit();
System::SystemInstance().SYS_vStart();
System::SystemInstance().SYS_vRun();
while(1)
{
;
}
}
这是iar输出。 IAR Output Console
如果有人遇到这样的问题,或者有人有任何解决方案或想法,请与我分享
感谢您的帮助:)
编辑: @rjp首先感谢您的回复。我在我的主板上使用了特殊框架,Quantum跃升了。这3个函数调用framwork函数,SYS_vRUN调用无限循环
int_t QF::run(void) {
onStartup(); // startup callback
// the combined event-loop and background-loop of the QV kernel
for (;;) {
R_WDT_Restart();
RepaintLCD();
delay_ms(50); /* Leave some room for the system to respond */
QF_INT_DISABLE();
if (QV_readySet_.notEmpty()) {
uint_fast8_t p = QV_readySet_.findMax();
QMActive *a = active_[p];
QF_INT_ENABLE();
// perform the run-to-completion (RTS) step...
// 1. retrieve the event from the AO's event queue, which by this
// time must be non-empty and The "Vanialla" kernel asserts it.
// 2. dispatch the event to the AO's state machine.
// 3. determine if event is garbage and collect it if so
//
QEvt const *e = a->get_();
a->dispatch(e);
gc(e);
}
else {
// QV::onIdle() must be called with interrupts DISABLED because
// the determination of the idle condition (no events in the
// queues) can change at any time by an interrupt posting events
// to a queue. QV::onIdle() MUST enable interrupts internally,
// perhaps at the same time as putting the CPU into a power-saving
// mode.
QP::QV::onIdle();
}
}
}
结束我搜索了exit()函数的所有代码,没有任何代码。但是你提到了关于断言的另一个问题。在这里你可以看到断言宏和客户实现的断言函数。
#define Q_ASSERT_ID(id_, test_) ((test_) \
? (void)0 : Q_onAssert(&Q_this_module_[0], (int_t)(id_)))
功能;
void Q_onAssert(char const Q_ROM * const file, int line) {
// implement the error-handling policy for your application!!!
QF_INT_DISABLE(); // disable all interrupts
// cause the reset of the CPU...
//WDTCTL = WDTPW | WDTHOLD;
//__asm(" push &0xFFFE");
// return from function does the reset
}
EDIT2: 大多数动态内存进程都在LedFactory类中完成。 头
/*
* LedFactory.h
*
* Created on: Aug 3, 2016
* Author: Dev
*/
#ifndef APPLICATION_LED_LEDFACTORY_H_
#define APPLICATION_LED_LEDFACTORY_H_
#include "LedController.h"
class LedFactory {
public:
typedef enum{
LED1,
LED2,
LED3,
LED4,
LED5,
LED6,
}LedTypes;
public:
LedFactory();
virtual ~LedFactory();
LedController * FirstLedFactory(LedTypes ledtype);
LedController * SecondLedFactory(LedTypes ledtype);
LedController * ThirdLedFactory(LedTypes ledtype);
LedController * FourthLedFactory(LedTypes ledtype);
LedController * FifthLedFactory(LedTypes ledtype);
LedController * SixthLedFactory(LedTypes ledtype);
public:
static LedFactory& instance();
};
#endif /* APPLICATION_LED_LEDFACTORY_H_ */
源文件。
/*
* LedFactory.cpp
*
* Created on: Aug 3, 2016
* Author: Dev
*/
#include <LedFactory.h>
#include "FirstLed.h"
#include "SecondLed.h"
#include "ThirdLed.h"
#include "FourthLed.h"
#include "FifthLed.h"
#include "SixthLed.h"
LedFactory::LedFactory() {
// TODO Auto-generated constructor stub
}
LedFactory::~LedFactory() {
// TODO Auto-generated destructor stub
}
LedFactory& LedFactory::instance()
{
static LedFactory instance;
return instance;
}
LedController * LedFactory::FirstLedFactory(LedTypes ledtype)
{
if(ledtype == (LedTypes)LED1)
{
return new FirstLed;
}
return NULL;
}
LedController * LedFactory::SecondLedFactory(LedTypes ledtype)
{
if(ledtype == (LedTypes)LED2)
return new SecondLed;
return NULL;
}
LedController * LedFactory::ThirdLedFactory(LedTypes ledtype)
{
if(ledtype == (LedTypes)LED3)
{
return new ThirdLed;
}
return NULL;
}
LedController * LedFactory::FourthLedFactory(LedTypes ledtype)
{
if(ledtype == (LedTypes)LED4)
{
return new FourthLed;
}
return NULL;
}
LedController * LedFactory::FifthLedFactory(LedTypes ledtype)
{
if(ledtype == (LedTypes)LED5)
{
return new FifthLed;
}
return NULL;
}
LedController * LedFactory::SixthLedFactory(LedTypes ledtype)
{
if(ledtype ==(LedTypes)LED6)
{
return new SixthLed;
}
return NULL;
}
我应该删除该类以增加动态分配内存问题吗? 或者我该如何解决这个问题?
答案 0 :(得分:-1)
问题已经解决了。主要原因是工厂级使用的动态内存分配过程。