Author Topic: JTAG as GPIO problem  (Read 14392 times)

Offline Adrian

  • Newbie
  • *
  • Posts: 13
    • View Profile
JTAG as GPIO problem
« on: April 30, 2010, 07:26:46 PM »
Hello, i've got small problem, can't set JTAG as GPIO
my def are:
#define J1_PORT_BIT    PORTC_BIT0
#define J1_PORT    GPIODATA_C
#define J1_DDR    GPIODIR_C
#define ENABLE_J1_PORT()    GPIODEN_C |= J1_PORT_BIT;
#define J1_JTAG_TO_GPIO    GPIOAFSEL_C |= ~(J1_PORT_BIT);
#define J1_OUTPUT    J1_DDR |= (J1_PORT_BIT);
#define J1_INPUT    J1_DDR &= ~ (J1_PORT_BIT);
#define J1_ONE    J1_PORT |= (J1_PORT_BIT);
#define J1_ZERO    J1_PORT &= ~ (J1_PORT_BIT);

and 10s after start:
J1_JTAG_TO_GPIO;
ENABLE_J1_PORT();
J1_OUTPUT;
J1_ZERO;

SO PORTC_BIT0 should be 0 but is 1, any help?

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3238
    • View Profile
    • uTasker
Re: JTAG as GPIO problem
« Reply #1 on: April 30, 2010, 07:47:26 PM »
Hi Adrian

I think that your problem is with

#define J1_JTAG_TO_GPIO    GPIOAFSEL_C |= ~(J1_PORT_BIT);

This causes all of port C to be set to peripheral use.

I believe that you wanted to write

#define J1_JTAG_TO_GPIO    GPIOAFSEL_C &= ~(J1_PORT_BIT);

This sets just C0 to output, with value '0' at the end.

Regards

Mark



Offline Adrian

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: JTAG as GPIO problem
« Reply #2 on: May 01, 2010, 08:18:09 AM »
oh i just checked it and it seems that there is still PORTC_BIT0 not set as output, i can even program my device after that , so there is problem that JTAG is still not active as GPIO
« Last Edit: May 01, 2010, 01:03:36 PM by Adrian »

Offline Adrian

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: JTAG as GPIO problem
« Reply #3 on: May 04, 2010, 08:43:45 PM »
OK , i've found solution , there is need to set those register:
GPIOLOCK_C = 0x1ACCE551;
GPIOCR_C = 0xFF;

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3238
    • View Profile
    • uTasker
Re: JTAG as GPIO problem
« Reply #4 on: May 04, 2010, 09:32:07 PM »
Hi Adrian

Yes, you are right - the register GPIOCR protects the JTAG pins to stop them being accidentally changed to GPIO.
In fact it seems as though the GPIOCR registers for all other ports and bits are not actually functional (the LM3S9BXX additionally protects the NMI pin in the same manner).

The GPIOCR is then protected by the GPIOLOCK register.

I have to admit to never using any of the JTAG pins as GPIO so never experienced this practically. It does mean that the simulator is not exact though because it doesn't monitor this detail, which I will look at improving.

Regards

Mark