8 years, 2 months ago.

P0_2 not working as DigitalOut on LPC824

Team

We are using W25X40BV in SPI. Using P0_2 as the chip select but it doesnt seem to go down to 0V when we set it to 0. We slowed down the operation to give us time to detect the voltage on P0_2

We also tried to use P0_2 as a separate DigitalOut and no effect their either

We changed the pin to P0_6 and it works well. Unfortunate I dont want to change the design now because p0_2 makes routing dramatically simpler.

I am wondering do i have to explicitly run SWM command to disable SWDIO and enable GPIO (P0_2)

LPC_SWM->PINENABLE0 = (LPC_SWM->PINENABLE0 & (1<<3)) | 1<<3; disable SWDIO @ P0.02

Appreciate team's help

Best Regards siva S

1 Answer

8 years, 2 months ago.

Which board are you using? Is it the LPC824 Xpresso? In that case the programmer part of the board is also connected to the SWDIO and may pull the pin high. In general I would recommend not to use the SWD pins for other purposes.

Accepted Answer

Wim Appreciate the quick response.

Yes its the xpresso baord http://www.embeddedartists.com/products/lpcxpresso/lpc824_xpr.php

Since I asked the question i have been messing with the swm and it seems to work the p0_2. However a zero doesnt pull the voltage to zero. It brings it only to about 0.45V

Ack. Next verson we will leave the P0_2 PIN

posted by siva surendar 19 Feb 2016

Checking the schematic of the 824xpresso shows that the programmer (an LPC11u35) has one of its pins connected to P0_2 of the target LPC824 thru a 270 ohm resistor. So assuming that the programmer pin is pulled up high, then the target LPC824 has to sink about 3V3/270 = 12 mA. (+ the current that your SPI device needs) when P0_2 is pulled low. That's not the max current for the high current output mode, but could still result in a non-0 output voltage when the pin is pulled low.

posted by Wim Huiskamp 19 Feb 2016

Wim or Team

Apologies for the long version

We were not able to make p0_2 work. We are able to move P0_2 TO GPIO and raise to 3.3v and drop to 0v in our board. YET its not reading the memory chip W25X40BV (in SPI). We are using p0_2 as Chip Select. Using p0_6 for Chip select works perfectly.

Further read of W25X40BV says Chip Select has to track Vcc on power up. I am wondering my setting p0_2 inside using folllowing is code is "too late"

LPC_SWM->PINENABLE0 = 0xfffffeffUL;

What I mean by that is p0_2 starts to behave like SWDIO and "does its own thing" on start up. and changes value of CS. Then we are setting it to GPIO n side main(). However the W25X40BV chip is "stuck" in some strange state since CS wasnt brought up in the same level of Vcc (on startup) since SWDIO messed with it

We tried tried to GND the W25X40BV chip on power and it didnt work at all. This would imply that if CS didnt come up with same level as Vcc then the W25X40BV is stuck in a non-operating mode

W25X40BV recommends to pull up Chip Select. But if SWDIO is going to bring it to 0V (because of some communication it thinks it has to do), pulling up CS wont work either right?

Can someone throw some light on this?

Siva S

posted by siva surendar 20 Feb 2016

I have never used the W25X40BV so cant say how it behaves on startup. Since it works OK when you use P0_6 instead of P0_2 it is likely that the initial traffic on P0_2 causes the issue. That pin will always start in SWDIO mode. However, I think it will wait for external commands from the SWD programmer before it does anything. In case of the LPCXpresso the programmer part may start some communication with the target immediately after a reset. You could try to remove the connection between the programmer and the target LPC824 to see if that works. This could be done by cutting a trace or by removing the 270 ohm series resistors. Obviously, you need to replace/restore that modification when you want to flash new firmware. Easiest and most robust solution is just to use P0_6 and not touch the SWD port pins.

posted by Wim Huiskamp 20 Feb 2016

Thanks. However I am getting this problem in my own cusotm board. I think using P0_6 may be the solution.

Thanks for your efforts and patience in answering

posted by siva surendar 20 Feb 2016