LPC1343 Newbie Question - GPIO stangeness

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC1343 Newbie Question - GPIO stangeness

516 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by josephfreiburg on Fri Mar 23 09:11:44 MST 2012
I sucessfully compiled and ran both the "blinky" and "systic" code from the NXP examples. I am using the Embedded Artists LPC1343 Quick Start board and the LPCxpresso debug interface. I then wanted to attach 8 LEDs to the GPIO1 bits 4-11 and let them turn on/off with the original code's LED (GPIO0 bit7). Everything worked except that bit 5 was always off and 6-7 were always on. Good, bit 4 blinked wildly, which was due to the JTAG interface. I tried the same thing with the systic code except this time with GPIO1 bits 0-7. In this case bits0-2 were always off and 3 again blinked as before.

I'm sure it's obvious, but what am I overlooking? Why don't the GPIO bits being addressed (using CMSIS 1.3 & GPIOSetDir / GPIOSetValue) work as I expected?

Kind Regards,
Joseph
0 Kudos
7 Replies

456 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by josephfreiburg on Mon Mar 26 02:06:10 MST 2012
Thanks!
0 Kudos

456 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sun Mar 25 03:56:54 MST 2012
And as mentioned in:

http://support.code-red-tech.com/CodeRedWiki/RedTraceOverview?highlight=%28swv%29

LPC_Link isn't using SWV (=SWO) :rolleyes:
0 Kudos

456 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by josephfreiburg on Sun Mar 25 03:15:07 MST 2012
I think the pinout shown by Code Red is generic and applies to  processors, which can support both JTAG and SWD. Since the LPC1343  supports only SWD, I gather I can safely use the PIO1 pins 0, 1 and 2.

For example, the Embedded Artists board connects to the LPC1343 pins shown before the "/" in the Code Red pinout:
Pin 2: PIO1_3-SWDIO
Pin 4: PIO0_10-SWCLK
Pin 6: PIO0_9-SWO
Pin 8: No Connection
Pin 10: PIO0_0-Reset
0 Kudos

456 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gbm on Sun Mar 25 03:11:01 MST 2012
Of course you can and should rely on reset values assuming you are sure nobody is changing them (like peripheral library calls). That's what makes your program short. If you don't trust the hardware and its definitive documents, you cannot use it at all.

For LPC11xx and 13xx parts, look at the default values of IOCON registers. Some of them are NOT GPIOs after reset.
0 Kudos

456 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sun Mar 25 02:52:47 MST 2012

Quote:

These apparently have something to do with JTAG. Since I'm using the LPCxpresso SWD debug interface I gather I can safely use these pins?

Yes, which pins are used by SWD is described here:

http://support.code-red-tech.com/CodeRedWiki/HardwareDebugConnections?action=show&redirect=CM3_SWD


Quote:

In general, is it usually good practise to explicity setup each GPIO pin before using it rather than rely on the default reset values?

Yes, relying on reset value can cause surprises (and default value could also been changed already) :rolleyes:
0 Kudos

456 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by josephfreiburg on Sun Mar 25 02:28:49 MST 2012
Thanks for the pointer to get me started! Quite obvious really, but there's a lot of new information to internalise...Yes, the pins are assigned to TDO, TMS and #TRST at reset. These apparently have something to do with JTAG. Since I'm using the LPCxpresso SWD debug interface I gather I can safely use these pins?

In general, is it usually good practise to explicity setup each GPIO pin before using it rather than rely on the default reset values? I would be inclined to simply write the cooresponding IOCON address with a single value and comment the configuration. Or is this bad practise (ex. because the reserved bits might someday change)?
0 Kudos

456 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Fri Mar 23 10:14:55 MST 2012
Did you use debugger to check IOCON_PIO1_x (Peripheral View-> IOCON)? If this registers are switched to another pin function, setting your GPIO registers is useless :eek:

To check your LED you can also set/reset bits in Peripheral->GPIO1 :)
0 Kudos