This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
MSP430F5438A RAM16KB 使用过程中,超过4K 编译0错误,0警告,下载到单片机,直接程序跑飞
以下是MAP
544 bytes of CODE memory
6 058 bytes of DATA memory (+ 4 absolute )
下载到单片机以后直接运行,调试按键全部失灵
DIsassembly
<unavailable when executing>
<unavailable when executing>
<unavailable when executing>
#include "driverlib.h"
#include "stdlib.h"
#include "string.h"
#include "task.h"
#include "MyGpio.h"
#include "Timer.h"
#include "Adc12.h"
#include "myUcs.h"
#include "485_uart.h"
#include "SSD128X64.h"
#include "RS232.h"
#include "W25q.h"
uint8_t Buffer[128];
uint8_t *Write ="Text 123456789";
static uint8_t Bufferer[3550] ={0};
//******************************************************************************
//!
//! Empty Project that includes driverlib
//!
//******************************************************************************
void main(void)
{
WDT_A_hold(WDT_A_BASE); //Stop watchdog timer
#if 0
// 一系列的初始化操作
//系统主频初始化
MainFrequencyInit();
//Gpio操作
GpioInit();
//定时器 1ms初始化
TimerInit1ms();
//485初始化
PcUart_Init();
//232初始化
RS232_Init();
//ADC 初始化
ADC12Init();
//SPI 初始化
W25QXX_Init();
//8080 OLED屏幕的初始化
SSD128X64_Init();
//任务的初始化
Task_Init();
_EINT(); //使能全局中断
//读取Flash ID
W25Q_Enable();
W25q_ReadId();
W25QXX_Write(Write,0x00,12);
W25QXX_Read(Buffer,0x00,128);
#endif
memcpy(Bufferer,0,3550);
while(1);
#if 0
while(1)
{
Task_Handle(); //任务处理函数
}
#endif
}
以上是我的代码,仅仅申请了一个数组不到16K的数组,也用咱们官方给的空程序例程,只申请一个数组,然后进行了拷贝操作,也是一样的问题
您是使用下面的代码配合例程内的空工程测试的?我这边可以正常下载
#include <msp430.h> #include "stdint.h" #include "string.h" uint8_t Buffer[128]={0}; uint8_t *Write ="Text 123456789"; static uint8_t Bufferer[3550] ={0}; /** * main.c */ int main(void) { WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer memcpy(Bufferer,0,3550); return 0; }
/* --COPYRIGHT--,BSD
* Copyright (c) 2017, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --/COPYRIGHT--*/
#include "driverlib.h"
#include "stdint.h"
#include "string.h"
//******************************************************************************
//!
//! Empty Project that includes driverlib
//!
//******************************************************************************
uint8_t Buffer[10240] ;
void main (void)
{
memcpy(Buffer,0,10240);
while(1);
}
以下是map 内容
108 bytes of CODE memory
10 400 bytes of DATA memory
那试下这个,刚才那个,我还有其他的地方定义了,数据 ,这个是咱们官方的,空程序,我直接申请内存 10k 我16KRAM 这个应该可以通过的
/* --COPYRIGHT--,BSD
* Copyright (c) 2017, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --/COPYRIGHT--*/
#include "driverlib.h"
#include "stdint.h"
#include "string.h"
//******************************************************************************
//!
//! Empty Project that includes driverlib
//!
//******************************************************************************
uint8_t Buffer[10240] ;
void main (void)
{
for(int i=0;i< 10240;i++)
{
Buffer[i ] =i;
__delay_cycles(150);
}
// memcpy(Buffer,0,10240);
while(1);
}
for 循环也是不可以的,
我使用了开发板提供的例程 (Backup of MSP-EXP439F5438_User_Experoence-User Experience F5438)如下
//**********************************************************************//******
// MSP-EXP430F5438 Experimenter's Board - User Experience Demo
// D. Dang
// Texas Instruments Inc.
// Ver 1.00 - May 2008
// Ver 1.10 - Jan 2009
// * Review, documentation of code
// * Removal of code for production test
// * Additional support for MSP430EXP5438 Rev 1.x
// Ver 1.20 - Oct 2009
// * Added support for F5438A (PMM & REF module)
// * Added support for use of TLV Device ID and ADC calibration values
// Built with Code Composer Studio v3.2
//**********************************************************************//******
#include "MSP-EXP430F5438 HAL\hal_MSP-EXP430F5438.h"
#include "stdint.h"
#include "string.h"
uint8_t Buffer[4096];
void main(void)
{
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
memcpy(Buffer,0,4096);
UserExperience();
}
这个例程 用memcpy 是没有任何问题的, 说明不是这个函数的问题,
问题解决了,需要重定义 __low_level_init 启动代码中会调用该函数,去关闭看门狗,现在很好奇的是,启动代码初始化,申请内存,能耗时那么久吗?
int __low_level_init(void)
{
WDTCTL = WDTPW + WDTHOLD;
/*==================================*/
/* Choose if segment initialization */
/* should be done or not. */
/* Return: 0 to omit seg_init */
/* 1 to run seg_init */
/*==================================*/
return (1);
}
The function __low_level_init is called by the start-up code before doing
the normal initialization of data segments. If the return value is zero,
initialization is not performed.
In the run-time library there is a dummy __low_level_init, which does
nothing but return 1. This means that the start-up routine proceeds with
initialization of data segments.
To replace this dummy, compile a customized version (like the example
below) and link it with the rest of your code.
很高兴您能解决问题!
__low_level_init默认是一个存根函数,在main初始化变量之前调用它。您可以来执行一些操作,例如在变量init之前禁用看门狗(如果您的大型数组初始化将花费很长时间),或者还有其他特殊情况。
另外您也可以使用__no_init__ uint8_t Buffer[4096] ;来不让编译器初始化大型数组