2001 views|0 replies

3836

Posts

19

Resources
The OP
 

GPIO Operation of TMS320C6748 [Copy link]

1. GPIO characteristics of TMS320C6748

Referring to the 1.2Features section of the TI technical document SPRUFL8B (TMS320C674x/OMAP-L1x Processor GPIO User's Guide), we can see that the GPIO of the TMS320C6748 has the following features:

1. The GOIO function can be set/cleared via separate data set and clear registers and the GPIO can be controlled by software without critical section protection (I don't understand this part of the original text)

2. Also supports set/clear function by writing a single output data register.

3. Independent output/input registers - The output register can be read to reflect the status of the output driver; the input register can be read to reflect the status of the pin.

4. All GPIO signals can be used as interrupt sources and have configurable edge detection.

5. All GPIO signals can be used to generate events to EDMA.

2. GPIO block diagram of TMS320C6748

From this we can see the various registers that control GPIO. This article only introduces the four registers DIR, SET_DATA, CLR_DATA, and INDATA.

3. Initialize GPIO steps

See "SPRUFL8B" 2.9 Initialization section

1. Set device pin multiplexing

2. Set PSC (Power and Sleep Control Register) to enable GPIO

3. Set the direction, data, and interrupt control registers to configure as needed

4. Introduction to StarterWare's GPIO library functions

To use the GPIO function of StarterWare, you need to add "gpio.c" or "C:\ti\C6748_StarterWare_1_20_04_01\binary\c674x\cgt_ccs\c6748\drivers\Debug\drivers.lib". In addition, you also need to add the header files "gpio.h", "soc_C6748.h", "hw_syscfg0_C6748.h", "hw_types.h". These header files define the physical addresses of many registers and the function macros used to calculate the address location.

1. Following the steps, let's first look at the multiplexed register PINMUXn. Because my development board uses GPIO2[8], I directly locate the PINMUX5 register:

We can see that GP2[8] is at bits 31-28 of PINMUX5, so we can set this bit to "1". The following figure shows the physical address of the PINMUX5 register:

We adopt the "read-mask-write" operation to avoid affecting the configuration of other bits. In hw_types.h, HWREG(x) (*((volatile unsigned int *)(x))) is defined, so we can set it as follows:

PINMUX_5_VAL=HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(5)); /* Read the value of PINMUX5 (multiplexing register) register*/
PINMUX_5_VAL=(PINMUX_5_VAL&0x0fffffff)|0x80000000;

HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(5))=PINMUX_5_VAL;/* Write the set value back to PINMUX5 register GP2[8] */

The value of SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(5) above is 0x1c14134, which is exactly the address of PINMUX5. StarterWare will calculate the address of a register under a peripheral according to the base address of the peripheral register, just like SOC_SYSCFG_0_REGS, which is defined as 0x01C14000 in line 289 of soc_C6748.h, and PINMUX5 is under this peripheral. SYSCFG0_PINMUX(n) (0x120 + (n * 4)) takes advantage of the fact that there are nine other registers between each PINMUXn, and each register is 32 bits for linear calculation.

2. Here, just use the default setting after hardware reset for PSC.

3. Set the input/output register. The library function defines void GPIODirModeSet(unsigned int baseAdd, unsigned int pinNumber, unsigned int pinDir); to set the input/output status of the IO port. Note that pinNumber has the following description in the function entry parameters:

The 144 GPIO pins have serial numbers from 1 to 144.
*GPIO0[0] 1 ,GPIO1[0] 17
* GPIO2[0] 33 ,GPIO3[0] 49
*GPIO4[0] 65 ,GPIO5[0] 81
*GPIO6[0] 97 ,GPIO7[0] 113
*GPIO8[0] 129

For example, if I want to set GPIO2[8] as output, then pinNumber=41.

GPIODirModeSet(SOC_GPIO_0_REGS, 41, GPIO_DIR_OUTPUT); can set GPIO2[8] to output; similarly, the principle of writing GPIO function is the same, but the calculation of register address is different, so it is not listed here. GPIOPinWrite(SOC_GPIO_0_REGS, 41, GPIO_PIN_HIGH); can make GPIO2[8] output high level. For the specific function of read operation, please refer to "C:\ti\C6748_StarterWare_1_20_04_01\drivers\gpio.c". In this way, we can easily operate GPIO!

This post is from DSP and ARM Processors
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list