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.

TM4C129XNCZAD如何配置JTAG口为普通IO用

如题,请问如何配置JTAG口为普通IO用,使用GPIOPinTypeGPIOOutput配置TDO,发现没有作用,TDO一直为高

  • JTAG口默认为下载口,需要解锁才可以配置为普通IO的。但是最好不要这么做,配置为普通IO的话,就无法下载仿真了,除非你使能串口或者usb下载。

  • 已配置成功,下载时直接接JLINK也能下载
    void GPIOorJTAG(uint8_t gpio_or_jtag) 
    { 
       if(gpio_or_jtag == 0) //配置为JTAG
       { 
           // Change PC0-3 into hardware (i.e. JTAG) pins.  First open the 
           // lock and select the bits we want to modify in the GPIO commit 
           // register. 
           // 
           HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY; 
           HWREG(GPIO_PORTC_BASE + GPIO_O_CR) = 0x0F; 
    
           // 
           // Now modify the configuration of the pins that we unlocked. 
           // 
           HWREG(GPIO_PORTC_BASE + GPIO_O_AFSEL) |= 0x0F; 
    
           // 
           // Finally, clear the commit register and the lock to prevent 
           // the pin configuration from being changed accidentally later. 
           // Note that the lock is closed whenever we write to the GPIO_O_CR 
           // register so we need to reopen it here. 
           // 
           HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY; 
           HWREG(GPIO_PORTC_BASE + GPIO_O_CR) = 0x00; 
           HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = 0; 
       } 
       else //配置为GPIO
       { 
           // 
           // Change PC0-3 into GPIO inputs. First open the lock and select 
           // the bits we want to modify in the GPIO commit register. 
           // 
           HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY; 
           HWREG(GPIO_PORTC_BASE + GPIO_O_CR) = 0x0F; 
    
           // 
           // Now modifiy the configuration of the pins that we unlocked. 
           // Note that the DriverLib GPIO functions may need to access 
           // registers protected by the lock mechanism so these calls should 
           // be made while the lock is open here. 
           // 
           HWREG(GPIO_PORTC_BASE + GPIO_O_AFSEL) &= 0xf0; 
           //这里配置GPIO
           GPIOPinTypeGPIOInput(GPIO_PORTC_BASE, GPIO_PIN_2);
           GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, GPIO_PIN_3);
           GPIOPadConfigSet(GPIO_PORTC_BASE, GPIO_PIN_3, GPIO_STRENGTH_12MA, GPIO_PIN_TYPE_STD);
    
           // 
           // Finally, clear the commit register and the lock to prevent 
           // the pin configuration from being changed accidentally later. 
           // Note that the lock is closed whenever we write to the GPIO_O_CR 
           // register so we need to reopen it here. 
           // 
           HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY; 
           HWREG(GPIO_PORTC_BASE + GPIO_O_CR) = 0x00; 
           HWREG(GPIO_PORTC_BASE + GPIO_O_LOCK) = 0; 
       } 
    }
  • 当配置为普通io使用的时候,如何才能下载呢?理论上是不可以的吧,你是如何实现的。

  • 当配置为普通io使用的时候,如何才能下载呢?理论上是不可以的吧,你是如何实现的。

    已配置成功,下载时直接接JLINK也能下载

  • 我试试这段代码。