简体   繁体   中英

CORTEX_M4_0: error occurs in GPIO code in debug mode

I am having this error whenever I try to debug my program using 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

I am using a Texas Instruments TM4C123GXL launchpad, and it connects to my laptop via a USB cable. I can successfully build my program, but the errors show up whenever I try to debug my program. My program is supposed to use SysTick interrupts to continuously vary the voltage on an Elegoo membrane switch module to allow the program to see which button I've pressed. I'm not 100% sure I've correctly initialized the GPIO input and output ports, but the errors occur before the program even starts and reaches my main loop.

Here is a screenshot of some code and my errors:

我的代码

Here is some 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
}

就我而言,我不得不禁用 GPIOHBCTL 寄存器中的 AHB(高级高性能总线)。

I found out why my error was occurring. I went to my professor and he had a custom-built device to check if my pins on my launchpad were working. It turns out some of the pins I was using on Port A and B drew too much current, and according to the custom-built device, became busted. In other words, this error came about because the IDE detected that some of my pins weren't operational anymore.

The Solution is to enable The clock getting into the peripheral using the RCC Section

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM