memory - 皮质_M4_0 : error occurs in GPIO code in debug mode

标签 memory hardware gpio

每当我尝试使用 Code Composer Studio V 9.1.0 调试我的程序时,我都会遇到此错误:

CORTEX_M4_0: Trouble Reading Memory Block at 0x400043fc on Page 0 of Length 0x4: Debug Port error occurred

我使用的是 Texas Instruments TM4C123GXL launchpad,它通过 USB 数据线连接到我的笔记本电脑。我可以成功构建我的程序,但每当我尝试调试我的程序时,错误就会出现。我的程序应该使用 SysTick 中断来连续改变 Elegoo 薄膜开关模块上的电压,以允许程序查看我按下了哪个按钮。我不能 100% 确定我是否已正确初始化 GPIO 输入和输出端口,但错误发生在程序启动并到达我的主循环之前。

这是一些代码和我的错误的截图:

My code

这是一些代码:

void SysTickInit()
{
    NVIC_ST_CTRL_R = 0;
    NVIC_ST_RELOAD_R = 0x0C3500; // delays for 10ms (800,000 in hex) '0x0C3500' is
    // original correct
    NVIC_ST_CURRENT_R = 0;
    NVIC_ST_CTRL_R = 0x07; // activates the systick clock, interrupts and enables it again.
}

void Delay1ms(uint32_t n)
{
    uint32_t volatile time;
    while (n)
    {
        time = 72724 * 2 / 91; // 1msec, tuned at 80 MHz
        while (time)
        {
            time--;
        }
        n--;
    }
}

void SysTick_Handler(void) // this function is suppose to change which port
// outputs voltage and runs every time systick goes
// to zero
{
    if (Counter % 4 == 0)
    {
        Counter++;
        GPIO_PORTA_DATA_R &= 0x00; // clears all of port A ( 2-5)
        GPIO_PORTA_DATA_R |= 0x04; // activates the voltage for PORT A pin 2
        Delay1ms(990);
    }
    else if (Counter % 4 == 1)
    {
        Counter++;
        GPIO_PORTA_DATA_R &= 0x00; // clears all of port A (2-5)
        GPIO_PORTA_DATA_R |= 0x08; // activates voltage for PORT A pin 3
        Delay1ms(990);
    }
    else if (Counter % 4 == 2)
    {
        Counter++;
        GPIO_PORTA_DATA_R &= 0x00; // clears all of port A (2-5)
        GPIO_PORTA_DATA_R |= 0x10; // activates voltage for PORT A pin 4
        Delay1ms(990);
    }
    else if (Counter % 4 == 3)
    {
        Counter++;
        GPIO_PORTA_DATA_R &= 0x00; // clears all of port A (2-5)
        GPIO_PORTA_DATA_R |= 0x20; // activates voltage for PORT A pin 5
        Delay1ms(990);
    }
}

void KeyPadInit()
{
    SYSCTL_RCGCGPIO_R |= 0x03; // turns on the clock for Port A and Port B
    while ((SYSCTL_RCGCGPIO_R) != 0x03) { }; // waits for clock to stabilize

    GPIO_PORTA_DIR_R |= 0x3C; // Port A pins 2-5 are outputs (i think)
    GPIO_PORTA_DEN_R |= 0x3C; // digitally enables Port A pins 2-5

    GPIO_PORTA_DIR_R &= ~0xC0; // makes Port A pin 6 and 7 inputs
    GPIO_PORTA_DEN_R |= 0XC0; // makes Port A pin 6 and 7 digitally enabled

    GPIO_PORTB_DIR_R &= ~0X03; // makes Port B pin 0 and 1 inputs
    GPIO_PORTB_DEN_R |= 0x03; // makes PortB pin 0 and 1 digitally enabled
}

最佳答案

我发现了我的错误发生的原因。我去找我的教授,他有一个定制的设备来检查我在发射台上的引脚是否正常工作。事实证明,我在端口 A 和 B 上使用的一些引脚消耗了太多电流,根据定制设备,这些引脚被破坏了。换句话说,这个错误是因为 IDE 检测到我的某些引脚不再可用。

关于memory - 皮质_M4_0 : error occurs in GPIO code in debug mode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59795308/

相关文章:

ffmpeg - 使用 dxva2 通过 ffmpeg 解码视频时无法执行 : 0x80070057,

python - 多个按钮 Raspberry Pi

linux - C代码中的段错误

java - 是否可以在java中将 secret 存储在堆栈上?

iphone - 在 iOS 4.0 上使用大图像时应用程序崩溃

c - 在 C 中取消引用包含指针的数组

c# - 如何最好地确定新应用程序的系统要求?

c++ - 用于控制光学媒体的 linux 应用程序

c - 为什么这个函数不能正确地打开和关闭 LED?

c - 没有操作系统的运行时内存分配