8 posts / 0 new
Last post
kqtrinh
Offline
Last seen:3 years 10 months ago
Joined:2016-08-24 00:17
GPIO pins assignments

Hi,

In our FW product application, we need to be able to use both the UART1 and UART2 along with SPI Flash access. UART1 and UART2 will be used to communicate with external devices with each attached to a device with UART line on the other end. My question is:

1. Can I have all three configured and assigned on the GPIO pins (as far as I know, there are 10 GPIO pins available for configuration)? If so, how?
2. As for SPI gpio pin assignment for Flash access, I need to be able to read/write/erase flash from the 580 processor. I read doc and the forum regarding SPI Flash and am still puzzel about whether the 580 should be Master or Slave. I believe it should be Master similar to the spi_flash sample application.

Thanks,
--Khai

Device:
MT_dialog
Offline
Last seen:2 months 3 weeks ago
Staff
Joined:2015-06-08 11:34
Hi kqtrinh,

Hi kqtrinh,

1. Yes you can configure your pins to any gpio functionallity you would like, what do you mean that there are 10 gpios available for configuration ? the qfn40 and 48 packages have 3 and 4 ports respectively. Please check the datasheet. The two UART modules are identical and they can be assigned and configured on different GPIOs the same for the single SPI module. Also the assignment of the peripherals on different pins is done by GPIO_ConfigurePin() and with the respective functionallity PID_UART1_RX / PID_UART2_RX / PID_SPI_DI etc.

2. If the SPI module should be master or slave depends on your application, the SPI module can operate in both modes, if your spi device that you would like to connect is a flash memory then the 580 should be a master on the SPI bus and the flash should be slave.

Thanks MT_dialog

kqtrinh
Offline
Last seen:3 years 10 months ago
Joined:2016-08-24 00:17
This is what I got from the

This is what I got from the v3.3 datasheet:

Digital interfaces
General purpose I/Os: 14 (WLCSP34 package),
24 (QFN40 package), 32 (QFN48 package)

It's talking about the number of pins for each 580 package type. However, when reading the code in gpio.h, I saw the emuns for GPIO_PORT with up to 4 ports as you said. We are going to use WLCSP34 package in you design. Does this package have 3 or 4 ports as well I assume?

Looking at the sample code for spi_flash, it uses GPIO port 0 for both UART2 and SPI. Although I can't see the text output that's printed to console thru UART2 due to my debug connection being in SPI mode, I assumed that it worked. When I am in UART mode, the text got printed out to Tera Term but then reading/writing SPI Flash becomes disabled.

I have that FTDI serial to UDB cable and followed the connection described in some doc. I can't seem to get both SPI and UART to work simultaneously for this application.

Thanks,
--Khai

MT_dialog
Offline
Last seen:2 months 3 weeks ago
Staff
Joined:2015-06-08 11:34
Hi kqtrinh,

Hi kqtrinh,

The datasheet indicates that the available GPIO's depends on the chip package, therefore you should choose a package that covers your needs. The WLCSP34 has the pins that are indicated in the datasheet, that means Ports 0 and 1 with the corresponding pins that are indicated in the datasheet. Port 2 is only for QFN40/48 and Port 3 is for QFN48 (page 5 on the DS_V3.3 as the notes indicate).

Regarding the UART and SPI functionality on the sample code, thats because the code reads and writes to the SPI and then prints the output to UART, there is no way for the processor to be used by both processes SPI and the UART. The 580 is not a multithread system.

Thanks MT_dialog

kqtrinh
Offline
Last seen:3 years 10 months ago
Joined:2016-08-24 00:17
I understand the 580 is not a

I understand the 580 is not a multi-thread system. But the spi_flash program is not a multi-thread application. It seemed to be executed each function sequentially (whether that be SPI flash access or UART out to console). There was no simultaneously flash access and UART write by two threads.

I thought the problem that I don't see the console print was because i am in SPI mode and not UART mode. By SPI mode I meant the J4 header was jumped according to the printed pin diagram on the far right of the J4 header while UART mode meant J4 jumped according to the pin diagram right next to it. That was why I mentioned the FTDI cable that was suggested to be used in some doc when in SPI mode to see the console output. I couldn't get this to work however.

If what the spi_flash program doing is an impossible thing to do, why was it being designed and coded up as such? The functionality in this sample app is exactly what I will need to achieve in our custom HW. I need to read data from Flash and push it over to the UART interface to another device on the other end to consume. You are saying this is impossible?

Thanks,
--Khai

MT_dialog
Offline
Last seen:2 months 3 weeks ago
Staff
Joined:2015-06-08 11:34
Hi kqtrinh,

Hi kqtrinh,

In order to operate the reads and writes to the spi flash and print from UART you will have to connect the appropriate jumper and pins, so you should be able to follow the diagram right beside the j4 header for the connection of the SPI flash, in order for data to be printed you need to place a jumper on the P04 port. If you do that you should see the data generated by the SPI transactions (without an external FTDI, by using the onboard ATMEL processor (no extra code or modification needed in order to do this - just plug the additional jumper).

Regarding the threads i mentioned above, was in order to make clear that you are not going to be able to make transactions with both of the peripherals at the same time.

Thanks MT_dialog

kqtrinh
Offline
Last seen:3 years 10 months ago
Joined:2016-08-24 00:17
OK, understood now.

OK, understood now.

With the DSPS peripheral mode code base, it uses UART1 to send text to console for display from phone.

As I mentioned before, our application requires the 580 processor to send command messages to devices attached to UART1 and UART2. I have the peripheral_init_setup.c code that have the following configurations for using UART1, UART2 and SPI:

void GPIO_reservations(void)
{
/*
* Globally reserved GPIOs reservation
*/
RESERVE_GPIO( UART1_TX, GPIO_UART1_TX_PORT, GPIO_UART1_TX_PIN, PID_UART1_TX);
RESERVE_GPIO( UART1_RX, GPIO_UART1_RX_PORT, GPIO_UART1_RX_PIN, PID_UART1_RX);

RESERVE_GPIO( UART2_TX, GPIO_UART2_TX_PORT, GPIO_UART2_TX_PIN, PID_UART2_TX);
RESERVE_GPIO( UART2_RX, GPIO_UART2_RX_PORT, GPIO_UART2_RX_PIN, PID_UART2_RX);

RESERVE_GPIO( SPI_EN, SPI_GPIO_PORT, SPI_CS_PIN, PID_SPI_EN);
RESERVE_GPIO( SPI_CLK, SPI_GPIO_PORT, SPI_CLK_PIN, PID_SPI_CLK);
RESERVE_GPIO( SPI_DO, SPI_GPIO_PORT, SPI_DO_PIN, PID_SPI_DO);
RESERVE_GPIO( SPI_DI, SPI_GPIO_PORT, SPI_DI_PIN, PID_SPI_DI);

#if (UART_HW_FLOW_ENABLED)
RESERVE_GPIO( UART1_RTS, GPIO_UART1_RTS_PORT, GPIO_UART1_RTS_PIN, PID_UART1_RTSN);
RESERVE_GPIO( UART1_CTS, GPIO_UART1_CTS_PORT, GPIO_UART1_CTS_PIN, PID_UART1_CTSN);
#endif /*UART_HW_FLOW_ENABLED*/
}
#endif //DEVELOPMENT_DEBUG

/**
****************************************************************************************
* @brief Map port pins
*
* The Uart and SPI port pins and GPIO ports are mapped
****************************************************************************************
*/
void set_pad_functions(void) // set gpio port function mode
{
// Enable UART2 for QPI1
GPIO_ConfigurePin( GPIO_UART1_TX_PORT, GPIO_UART1_TX_PIN, OUTPUT, PID_UART1_TX, false );
GPIO_ConfigurePin( GPIO_UART1_RX_PORT, GPIO_UART1_RX_PIN, INPUT_PULLUP, PID_UART1_RX, false );

// Enable UART2 for QPI2
GPIO_ConfigurePin( GPIO_UART2_TX_PORT, GPIO_UART2_TX_PIN, OUTPUT, PID_UART2_TX, false );
GPIO_ConfigurePin( GPIO_UART2_RX_PORT, GPIO_UART2_RX_PIN, INPUT_PULLUP, PID_UART2_RX, false );

#if (UART_HW_FLOW_ENABLED)
GPIO_ConfigurePin (GPIO_UART1_RTS_PORT GPIO_UART1_RTS_PIN, OUTPUT, PID_UART1_RTSN, false );
GPIO_ConfigurePin (GPIO_UART1_CTS_PORT GPIO_UART1_CTS_PIN, INPUT_PULLUP, PID_UART1_CTSN, false );

GPIO_ConfigurePin( GPIO_UART2_RTS_PORT, GPIO_UART2_RTS_PIN, OUTPUT, PID_UART2_RTSN, false );
GPIO_ConfigurePin( GPIO_UART2_CTS_PORT, GPIO_UART2_CTS_PIN, INPUT_PULLUP, PID_UART2_CTSN, false );
#endif //UART_HW_FLOW_ENABLED

// Configuring SPI Flash
GPIO_ConfigurePin(SPI_GPIO_PORT, SPI_CS_PIN, OUTPUT, PID_SPI_EN, true);
GPIO_ConfigurePin(SPI_GPIO_PORT, SPI_CLK_PIN, OUTPUT, PID_SPI_CLK, false);
GPIO_ConfigurePin(SPI_GPIO_PORT, SPI_DO_PIN, OUTPUT, PID_SPI_DO, false);
GPIO_ConfigurePin(SPI_GPIO_PORT, SPI_DI_PIN, INPUT, PID_SPI_DI, false);
}

How do I switch to the correct UART channel if I want to communicate with device attaching to UART1 or UART2?

Thanks,
--Khai

MT_dialog
Offline
Last seen:2 months 3 weeks ago
Staff
Joined:2015-06-08 11:34
Hi kqtrinh,

Hi kqtrinh,

Please dont post additional questions to an irreleveant topic, for a new question you can always create a new thread.

Regarding your questions the UART and UART2 modules are using different drivers that set different registers for each UART module, for example in DSPS the UART that is used from the application uses the uart_sps_init(), that initializes UART. Also DSPS is using UART2 in order print out some debugging messages, so if you have the CFG_PRINTF_UART2 the uart2 module is initialized by the uart2_init() function. So, for each uart module there are the corresponding drivers who control the corresponding uart registers.

Thanks MT_dialog