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.
大家好,我正在开发一个程序,在这个程序中,按下一个按钮,就会使用driverlib函数FRAM_MEMoryFill32将变量'data'中存储的值写入FRAM。 我一直在调试一个打开的监视窗口来跟踪变量'press'和'data'。 第一次按下按钮时,中断被启用,'data'的第一个值被写入内存。 但是,在随后按下按钮时,'data'中存储的值不再重写,并重置回零。 'press'(压力)也会重置回零。 这是我的代码:
#include "driverlib.h" #include "MSP4S.h" #include "intrinsics.h" #include "stdio.h" #define FRAM_test_start 0x4800 //将FRAM中的初始位置定义为地址0x4800 unsigned int press =0; //初始化变量'press' UINT32_t数据=0; //初始化32位'data'变量 int main(void){ WDT_A_HOLD (WDT_A_BASE); //停止监视程序计时 器PMM_UNlockLPM5 (PMM_BASE); //解锁销 GPIO _setAsInputPin (GPIO_PORT_P1, GPIO _PIN1); //将WFP 1.1 设置为输入 GPIO_setAsInputPinWithPullUprefistor (GPIO_PORT_P1, GPIO_PIN1);//设置1.1 WFP上拉电阻 器GPIO断路器EdgeSelect(GPIO_PORT_P1, GPIO_PIN1, GPIO _高_至_低_转换); GPIO _启用中断(GPIO_PORT_P1, GPIO _PIN1); //启用WFP 1.1 上的中断 GPIO GPIO GPIO清除InterruptFlag(GPIO_PORT_P1, GPIO PIN1); //清除WFP 1.1 上的中断标志 GPIO _setAsOutputPin (GPIO端口P1,GPIO _PIN0); //将WFP 1.0 设置为输出 GPIO_setOutputLowOnPin (GPIO_PORT_P1, GPIO_PIN0); //初始化WFP 1.0 为低 GPIO _setAsOutputPin (GPIO_PORT_P9, GPIO _PIN7); //将WFP 9.7 设置为输出 GPIO _setOutputHighOnPin (GPIO_PORT_P9, GPIO _PIN7); //将WFP 9.7 初始化为高 fRAM_MEMoryFill32 (FRAM_BASE,DATA,(UINT32_t*) FRAM_TEST_START,128); //输入LPM3 __bis_sr_register (LPM0_bits+GIE);//输入LPM0 //__no_operation(); } //按钮的ISR 1.1 #pragma vector=Port1_vector __interrupt void Port_1 (void){ //跳转 __delay_cycles (6.4万); //如果 ((P1IN & BIT1)!= BIT1){ 按+=1; //递增按钮计数 如果(按< 10并按> 0){ Data += 0x1.0001万; } 否则{ 按= 0; 数据= 0x0万00000; }0万} } GPIO _toggleOutputOnPin (GPIO_PORT_P1, GPIO _PIN0);//切换两个输出LED GPIO _toggleOutputOnPin (GPIO_PORT_P9, GPIO _PIN7); fRAM_memoryFill32 (fRAM_BASE,DATA,(UINT32_t*) fRAM_test_start,128); GPIO_clearInterruptFlag(GPIO_PORT_P1, GPIO_PIN1);//清除WFP 1.1 上的中断标志 }