This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello TI support team,
My hardware is H/W: TMS570MCU HDK
I am confused about how to configure the MibSPI as GPIO,
HALCoGen generate:
/** @def mibspiREG1
* @brief MIBSPI1 Register Frame Pointer
*
* This pointer is used by the MIBSPI driver to access the mibspi module registers.
*/
#define mibspiREG1 ((mibspiBASE_t *)0xFFF7F400U)
/** @def mibspiPORT1
* @brief MIBSPI1 GIO Port Register Pointer
*
* Pointer used by the GIO driver to access I/O PORT of MIBSPI1
* (use the GIO drivers to access the port pins).
*/
#define mibspiPORT1 ((gioPORT_t *)0xFFF7F418U)
which one should I use, 0xFFF7F400U or 0xFFF7F418U?
what is the default state of the MIBSPI1 after reset? GPIO or SPI?
If I want to use mibspiPORT1 to configure the port, I could not find any spec. How to configure the port as GPIO?
Thanks
Jun
Jun,
After reset all pins on MIBSPI are by default in GIO mode (fun=0).
The following definition is used by the GIO driver.
/** @def mibspiPORT1
* @brief MIBSPI1 GIO Port Register Pointer
*
* Pointer used by the GIO driver to access I/O PORT of MIBSPI1
* (use the GIO drivers to access the port pins).
*/
#define mibspiPORT1 ((gioPORT_t *)0xFFF7F418U)
The GIO structure for the MIBSPI is the same as the one for the GIO module itself.
If you plan to use the MIBSPI pins as simple I/Os, and control the direction, In and Out, than you have to enable the GIO driver in HalcoGen.
This will provide you with the functions necessary to control the MIBSPI pins. Here are some examples:
void gioSetDirection(gioPort_t *port, uint32_dir) // Set the direction of GIO pins at run time
void gioSetBit(gioPort_t *port, uint32_t bit, uint32_t value) // Writes a value to the specified pin of given GIO port
Look the GIO.C file to see all the function available.
To use the function, use this example:
gioSetDirection(mibspiPORT1,0x01); // This will set the MIBSPI1_CS(0) as output
Please let me know if I've answered your question.
Thanks and Regards,
Jean-Marc
Hi
I have TMS470M HDK, configure by Halcogen 03.05.02 and CCS 5.4.
I want use MibSPI as GIO, but
#define spiPORT1 ((gioPORT_t *)0xFFF7F418U)
gioSetDirection(spiPORT1, 0x01);
gioSetBit(spiPORT1, 0, 0);
not worked. I tried also:
gioSetDirection(gioPORTA, 0xFF);
gioSetBit(gioPORTA, 0, 1);
But on pins[5,6,15,16] is low level, and pins[26-34] is high level independently of gioSetBit function.
how the addressable MibSPI as GIO pins, CAN as GIO pins? MIBSPI1CLK pin can be programmed as a GIO pin? there is no error in the datasheet?
Please, help me.
Roman,
In order to use the GIO or the MIBSPI as general purpose I/Os it is necessary to initialize the module.
Using the gioSetDirection() and gioSetBit() is not enough.
Here is a sample main() code
void main(void)
{
/* USER CODE BEGIN (2) */
spiREG1->GCR0 = 1U; /** bring SPI out of reset */
// spiInit();
gioREG->GCR0 = 1U; /** bring GIO module out of reset */
// gioInit();
gioSetDirection(spiPORT1,1);
gioSetBit(spiPORT1,0,1);
gioSetDirection(gioPORTA,0xff);
gioSetBit(gioPORTA,0,1);
/* USER CODE END */
}
The module initialization is normally done via the initXXX();
If your plan it only to use the I/Os and don't plan to use the MIBSPI, you can just put the MIBSPI out of reset using:
spiREG1->GCR0 = 1U; /** bring SPI out of reset */
This will avoid the overhead of the full MIBSPI Init.
I've attached a zip file with the full project, including HalCoGen.
Please let me know if this is working for you.7752.MIBSPI_GIO.zip
Thank you for the input.
I have been using HalCoGen, and the function of the pin was set to GIO.
I did just find the answer, but not sure why it worked.
Even though the function was set to GIO, I also had the SPI_CS output open drain enable set and pullup set.
I changed this in HalCoGen and the pin is working fine.
Here is the code change in spi.c:
WAS:
/** - SPI1 Port open drain enable */
spiREG1->PC6 = (uint32)((uint32)1U << 0U) /* SCS[0] */
| (uint32)((uint32)1U << 1U) /* SCS[1] */
| (uint32)((uint32)1U << 2U) /* SCS[2] */
IS:
/** - SPI1 Port open drain enable */
spiREG1->PC6 = (uint32)((uint32)0U << 0U) /* SCS[0] */
| (uint32)((uint32)0U << 1U) /* SCS[1] */
| (uint32)((uint32)0U << 2U) /* SCS[2] */