Is posible use SWDIO pin PIO1_3 like GPIO and reprogrammer?
I reprogramming LPC11C24 controller on my firmware use PIO1_3(SWDIO) like GPIO. Posteriorly microcontroller can't reprogramming.
Hi Alain Arri ,
Thank you for your interest in NXP Semiconductor products and the opportunity to serve you.
1) Is posible use SWDIO pin PIO1_3 like GPIO and reprogrammer?
I think so, you can share some codes about the demo and it can help me to work it out.
Have a great day,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
gpio initialization code:
#include "gpio.h"
#define outRS485EN_port 0 //
#define outRS485EN_pin 0 //
#define outPIN0_port 1 //
#define outPIN0_pin 1 //
#define outPIN1_port 1 //
#define outPIN1_pin 2 //
#define outPIN2_port 1 //
#define outPIN2_pin 3 //
#define outPIN3_port 1 //
#define outPIN3_pin 4 //
#define outPIN4_port 3 //
#define outPIN4_pin 0 //
#define outPIN5_port 3 //
#define outPIN5_pin 1 //
#define outPIN6_port 3 //
#define outPIN6_pin 2 //
#define outPIN7_port 3 //
#define outPIN7_pin 3 //
#define inPIN0_port 1 //
#define inPIN0_pin 0 //
#define inPIN1_port 1 //
#define inPIN1_pin 5 //
#define inPIN2_port 1 //
#define inPIN2_pin 8 //
#define inPIN3_port 2 //
#define inPIN3_pin 0 //
#define inPIN4_port 2 //
#define inPIN4_pin 1 //
#define inPIN5_port 2 //
#define inPIN5_pin 2 //
#define inPIN6_port 2 //
#define inPIN6_pin 3 //
#define inPIN7_port 2 //
#define inPIN7_pin 6 //
void gpio_init(void)
{
//Configuramos los pines del puerto serie UART
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO1_6, (IOCON_FUNC1 | IOCON_MODE_INACT));/* RXD */
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO1_7, (IOCON_FUNC1 | IOCON_MODE_INACT));/* TXD */
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO1_0, (IOCON_FUNC1 | IOCON_MODE_INACT));/*Dig input PIN0 input */
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO1_5, (IOCON_FUNC0 | IOCON_MODE_INACT));/*Dig input PIN1 input */
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO1_8, (IOCON_FUNC0 | IOCON_MODE_INACT));/*Dig input PIN2 input */
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO2_0, (IOCON_FUNC0 | IOCON_MODE_INACT));/*Dig input PIN3 input */
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO2_1, (IOCON_FUNC0 | IOCON_MODE_INACT));/*Dig input PIN4 input */
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO2_2, (IOCON_FUNC0 | IOCON_MODE_INACT));/*Dig input PIN5 input */
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO2_3, (IOCON_FUNC0 | IOCON_MODE_INACT));/*Dig input PIN6 input */
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO2_6, (IOCON_FUNC0 | IOCON_MODE_INACT));/*Dig input PIN7 input */
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO1_1, (IOCON_FUNC1 | IOCON_MODE_INACT));/*Dig output PIN0 outptu */
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO1_2, (IOCON_FUNC1 | IOCON_MODE_INACT));/*Dig output PIN1 outptu */
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO1_3, (IOCON_FUNC1 | IOCON_MODE_INACT));/*Dig output PIN2 outptu */
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO1_4, (IOCON_FUNC0 | IOCON_MODE_INACT));/*Dig output PIN3 outptu */
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO3_0, (IOCON_FUNC0 | IOCON_MODE_INACT));/*Dig output PIN4 outptu */
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO3_1, (IOCON_FUNC0 | IOCON_MODE_INACT));/*Dig output PIN5 outptu */
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO3_2, (IOCON_FUNC0 | IOCON_MODE_INACT));/*Dig output PIN6 outptu */
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO3_3, (IOCON_FUNC0 | IOCON_MODE_INACT));/*Dig output PIN7 outptu */
//configurar I2C
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO0_4, IOCON_FUNC1 | I2C_FASTPLUS_BIT);
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO0_5, IOCON_FUNC1 | I2C_FASTPLUS_BIT);
//configuramos el pin de enable del rs485
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO0_0, (IOCON_FUNC1 | IOCON_MODE_INACT));/*Como salida*/
Chip_GPIO_SetPinDIROutput(LPC_GPIO, outRS485EN_port, outRS485EN_pin );
Chip_GPIO_WritePortBit(LPC_GPIO, outRS485EN_port, outRS485EN_pin, false);
//configuramos pines de salida puerto digital, todas las salidas a 0vdc
Chip_GPIO_SetPinDIROutput(LPC_GPIO, outPIN0_port, outPIN0_pin );
Chip_GPIO_WritePortBit(LPC_GPIO, outPIN0_port, outPIN0_pin, false);
Chip_GPIO_SetPinDIROutput(LPC_GPIO, outPIN1_port, outPIN1_pin );
Chip_GPIO_WritePortBit(LPC_GPIO, outPIN1_port, outPIN1_pin, false);
Chip_GPIO_SetPinDIROutput(LPC_GPIO, outPIN2_port, outPIN2_pin );
Chip_GPIO_WritePortBit(LPC_GPIO, outPIN2_port, outPIN2_pin, false);
Chip_GPIO_SetPinDIROutput(LPC_GPIO, outPIN3_port, outPIN3_pin );
Chip_GPIO_WritePortBit(LPC_GPIO, outPIN3_port, outPIN3_pin, false);
Chip_GPIO_SetPinDIROutput(LPC_GPIO, outPIN4_port, outPIN4_pin );
Chip_GPIO_WritePortBit(LPC_GPIO, outPIN4_port, outPIN4_pin, false);
Chip_GPIO_SetPinDIROutput(LPC_GPIO, outPIN5_port, outPIN5_pin );
Chip_GPIO_WritePortBit(LPC_GPIO, outPIN5_port, outPIN5_pin, false);
Chip_GPIO_SetPinDIROutput(LPC_GPIO, outPIN6_port, outPIN6_pin );
Chip_GPIO_WritePortBit(LPC_GPIO, outPIN6_port, outPIN6_pin, false);
Chip_GPIO_SetPinDIROutput(LPC_GPIO, outPIN7_port, outPIN7_pin );
Chip_GPIO_WritePortBit(LPC_GPIO, outPIN7_port, outPIN7_pin, false);
Chip_GPIO_SetPinDIRInput(LPC_GPIO, inPIN0_port, inPIN0_pin );
Chip_GPIO_SetPinDIRInput(LPC_GPIO, inPIN1_port, inPIN1_pin );
Chip_GPIO_SetPinDIRInput(LPC_GPIO, inPIN2_port, inPIN2_pin );
Chip_GPIO_SetPinDIRInput(LPC_GPIO, inPIN3_port, inPIN3_pin );
Chip_GPIO_SetPinDIRInput(LPC_GPIO, inPIN4_port, inPIN4_pin );
Chip_GPIO_SetPinDIRInput(LPC_GPIO, inPIN5_port, inPIN5_pin );
Chip_GPIO_SetPinDIRInput(LPC_GPIO, inPIN6_port, inPIN6_pin );
Chip_GPIO_SetPinDIRInput(LPC_GPIO, inPIN7_port, inPIN7_pin );
main:
void UART_IRQHandler(void)
{
IRQPC(&PCDataValue);
}
int main(void)
{
//uint8_t a;
SystemCoreClockUpdate();
// Set up and initialize all required blocks and
// functions related to the board hardware
Board_Init();
//WatchdogInitialize();
Chip_WWDT_Feed(LPC_WWDT);
gpio_init();//< GPIO initialization.
//inicializar uart
initPC(&PCDataValue);
//iniciar puerto I2C
init_I2C();
// TODO: insert code here
initCPU();
// Enter an infinite loop, just incrementing a counter
while(1)
{
Chip_WWDT_Feed(LPC_WWDT);
//printf("while\n");
if(PCDataValue.flgDataToRead==true)
{
//printf("Datos recibidos\n");
if(readPCdata(&PCDataValue)==true)
{
//miramos si el ID de unidade de test corresponde con el recibido por el puerto serie
if(IdUnitTest==PCDataValue.lIdUnitTest)
{
//miramos el mensaje para que PCB corresponde
switch(PCDataValue.IdPCB)
{
case 0x01://corresponde a la placa CPU
comandoCPU(&PCDataSend, &PCDataValue);
break;
case 0x02:
comandoAlaogIO(&PCDataSend, &PCDataValue);
break;
}
sendDataPC(&PCDataSend);
}
}
else
{
if(IdUnitTest==PCDataValue.lIdUnitTest)
{
//devolver error
PCDataSend.lIdUnitTest=IdUnitTest;
PCDataSend.IdPCB=0x01;
PCDataSend.Command=0x0001;
PCDataSend.dataLength=1;
if(PCDataValue.flgCRCError==true)
PCDataSend.Data[0]=ERROR_CRC;
else
PCDataSend.Data[0]=ERROR_GENERAL;
sendDataPC(&PCDataSend);
}
}
}
}
return 0 ;
}