µTasker Forum

µTasker Forum => Luminary Micro TM LM3SXXXX => Topic started by: Adrian on April 30, 2010, 07:26:46 PM

Title: JTAG as GPIO problem
Post by: Adrian 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?
Title: Re: JTAG as GPIO problem
Post by: mark 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


Title: Re: JTAG as GPIO problem
Post by: Adrian 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
Title: Re: JTAG as GPIO problem
Post by: Adrian 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;
Title: Re: JTAG as GPIO problem
Post by: mark 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