Hi,
I read example projects of Tiva-C 1294. There are many similar uses ' GPIOPinWrite(GPIO_PORTH_BASE, GPIO_PIN_2, GPIO_PIN_2);'
The prototype is :
extern void GPIOPinWrite(uint32_t ui32Port, uint8_t ui8Pins, uint8_t ui8Val);
The last parameter is a value, not a pin. I have asked the question on TI forum. I know that it is bit-banding, but that answer lacks detail on why it is bit-banding, it is set to '1' or clear to '0'?
Could you tell me more the line on GPIO_PIN_2?
Thanks,
void EK_TM4C1294XL_initWiFi(void)
void
EK_TM4C1294XL_initWiFi(
)
{
/* Configure EN & CS pins to disable CC3100 */
GPIOPinTypeGPIOOutput(GPIO_PORTH_BASE, GPIO_PIN_2);
GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, GPIO_PIN_6);
GPIOPinWrite(GPIO_PORTH_BASE, GPIO_PIN_2, GPIO_PIN_2);
GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_6, 0);
I do not know so much about what the GPIO pins are connected to, but I might be able to provide some more information on bit-banding.
I think, though, that...
...should have been...
GPIOPinWrite(GPIO_PORTH_BASE, GPIO_PIN_2, 1);
... I'm convinced it would do the exact same thing, as I expect GPIO_PIN_2 to be non-zero.
-That is, of course, if the function is a true bit-banding function.
If it's just using data and masks, then GPIO_PIN_2 would be correct.
In any case, the line for GPIO_PIN_2 will set GPIO pin 2 on Port H to high.
Bit-banding is a different way of addressing, so that you can change a single bit on one go, instead of reading a whole byte, change it and write it back.
For instance, a device might have an on-chip SRAM starting at 0x20000000 and a Bit-band region starting at 0x22000000.
If you want to set bit 3 in address 0x20000000, you could do it this way:
1: read contents of address 0x20000000 into a variable or register
2: change bit 3
3: write the variable or register's value back to address 0x20000000
-But instead, you could use bit-banding.
You just need to write a non-zero value to address 0x22000004 in order to set the bit.
Writing a zero to the same address clears the bit.
Thus the above function will do it all for you; it only changes a single bit at a time, leaving the other bits untouched.
-You don't have to do any calculations in order to access the bitband if you use the function.
Hello,
I think the statements are not related with the bit-banding.
I think they are just GPIO settings.
I guess that GPIO_PIN_2 would be 0x4 (i.e. bit2 is 1).
So,
means set GPIOH[2] to '1'.
Also,
means set GPIOC[6] to '0'.
Best regards,
Yasuhiko Koumoto.