Content originally posted in LPCWare by cosborne2000 on Tue Jun 24 09:41:24 MST 2014 The reference manual states that you cannot assign multiple outputs to a pin.
When I assign an output to a pin that has been used previously, does the new value overwrite the old or do I need to move any previous output function to pin 255?
Content originally posted in LPCWare by mubes on Thu Jun 26 01:59:05 MST 2014 Ah, I hadn't thought it through. I went to look at my code;
I switch the pin from MISO to a GPIO ... which is effectively returning it to it's 0xFF function;
case SPI_DEVICE_OLED:
// Switch MISO to be the C/D pin
LPC_SWM->PINASSIGN4=(LPC_SWM->PINASSIGN4&0xFFFF0000)|(SPI_MOSI)|0xFF00;
LPC_GPIO_PORT->DIR0 |= (1 << SPI_MISO);
break;
...of course, if you were putting a new function out on the pin, it would be a good idea to remove the old function first One thing I've not tried yet is putting the same function out through multiple pins at the same time. I had a bright idea about doing that to set the RGB colour on a VGA bit driver from the SPI shift register, but not got around to trying it yet.
Thanks for the course correction.
DAVE (Edited because of silly error when cutting/pasting code, which made the code invalid)
Content originally posted in LPCWare by starblue on Thu Jun 26 01:07:04 MST 2014 Quote: mc In this case you will have to disassociate previous function to pin.
Will assigning two output functions with different logic levels damage the chip? Or will the chip prevent that?
Content originally posted in LPCWare by mc on Wed Jun 25 07:06:00 MST 2014 Hi Dave, There are two scenarios.
1) Assigning one function to different pins at different time. This can be done.
2) Assuming that cosborne2000 is assigning two functions to same pin. This can be done by two separate PINASSIGNx registers or separate byte of one PINASSIN register. In this case you will have to disassociate previous function to pin.
Content originally posted in LPCWare by mubes on Wed Jun 25 03:13:16 MST 2014 Oh, this is interesting...and I may well be doing it wrong then! Given that writing a new value into the register allocates its new function what is the purpose of going via the dissociation first?
Content originally posted in LPCWare by mc on Tue Jun 24 13:07:50 MST 2014 Hi cosborne2000, Before assigning new function to a pin, please dissociate previous function assigned to this pin.
Content originally posted in LPCWare by mubes on Tue Jun 24 11:42:17 MST 2014 I always just replace the old with the new (I do it frequently to turn the MISO pin into a command/data pin for a write-only OLED)....not seen any problems so far.