Part Number: TM4C129ENCZAD
I have a TM4C129ENCZAD microcontroller I am using to control GPIO through Telnet. I have modified the shell environment to control GPIO outputs through telnet via some simple commands.
A GPIO in is turned off with the following code,
static void open(char *str)
{
if (str[1] == '0'){
ROM_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_6, 0);
shell_output("<0>","");
}
if (str[1] == '1'){
ROM_GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5, 0);
shell_output("<0>","");
}
if (str[1] == '2'){
ROM_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_4, 0);
shell_output("<0>","");
}
if (str[1] == '3'){
ROM_GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_4, 0);
shell_output("<0>","");
}
if (str[1] == '4'){
ROM_GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_6, 0);
shell_output("<0>","");
}
if (str[1] == '5'){
ROM_GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_1, 0);
shell_output("<0>","");
}
if (str[1] == '6'){
ROM_GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_3, 0);
shell_output("<0>","");
}
if (str[1] == '7'){
ROM_GPIOPinWrite(GPIO_PORTQ_BASE, GPIO_PIN_1, 0);
shell_output("<0>","");
}
if (str[1] == '8'){
ROM_GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_7, 0);
shell_output("<0>","");
}
if (str[1] == '9'){
ROM_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_2, 0);
shell_output("<0>","");
}
if (str[1] == 'A'){
ROM_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_1, 0);
shell_output("<0>","");
}
if (str[1] == 'B'){
ROM_GPIOPinWrite(GPIO_PORTK_BASE, GPIO_PIN_0, 0);
shell_output("<0>","");
}
if (str[1] == 'C'){
ROM_GPIOPinWrite(GPIO_PORTK_BASE, GPIO_PIN_2, 0);
shell_output("<0>","");
}
if (str[1] == 'D'){
ROM_GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_6, 0);
shell_output("<0>","");
}
if (str[1] == 'E'){
ROM_GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_5, 0);
shell_output("<0>","");
}
if (str[1] == 'F'){
ROM_GPIOPinWrite(GPIO_PORTJ_BASE, GPIO_PIN_6, 0);
shell_output("<0>","");
}
if (str[1] == 'G'){
ROM_GPIOPinWrite(GPIO_PORTR_BASE, GPIO_PIN_5, 0);
shell_output("<0>","");
}
if (str[1] == 'H'){
ROM_GPIOPinWrite(GPIO_PORTH_BASE, GPIO_PIN_2, 0);
shell_output("<0>","");
}
if (str[1] == 'I'){
ROM_GPIOPinWrite(GPIO_PORTH_BASE, GPIO_PIN_3, 0);
shell_output("<0>","");
}
if (str[1] == 'J'){
ROM_GPIOPinWrite(GPIO_PORTH_BASE, GPIO_PIN_6, 0);
shell_output("<0>","");
}
}
A GPIO pin is turned on with the following code,
static void close(char *str)
{
if (str[1] == '0'){
ROM_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_6, GPIO_PIN_6);
shell_output("<1>","");
}
if (str[1] == '1'){
ROM_GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5, GPIO_PIN_5);
shell_output("<1>","");
}
if (str[1] == '2'){
ROM_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_4, GPIO_PIN_4);
shell_output("<1>","");
}
if (str[1] == '3'){
ROM_GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_4, GPIO_PIN_4);
shell_output("<1>","");
}
if (str[1] == '4'){
ROM_GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_6, GPIO_PIN_6);
shell_output("<1>","");
}
if (str[1] == '5'){
ROM_GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_1, GPIO_PIN_1);
shell_output("<1>","");
}
if (str[1] == '6'){
ROM_GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_3, GPIO_PIN_3);
shell_output("<1>","");
}
if (str[1] == '7'){
ROM_GPIOPinWrite(GPIO_PORTQ_BASE, GPIO_PIN_1, GPIO_PIN_1);
shell_output("<1>","");
}
if (str[1] == '8'){
ROM_GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_7, GPIO_PIN_7);
shell_output("<1>","");
}
if (str[1] == '9'){
ROM_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_2, GPIO_PIN_2);
shell_output("<1>","");
}
if (str[1] == 'A'){
ROM_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_1, GPIO_PIN_1);
shell_output("<1>","");
}
if (str[1] == 'B'){
ROM_GPIOPinWrite(GPIO_PORTK_BASE, GPIO_PIN_0, GPIO_PIN_0);
shell_output("<1>","");
}
if (str[1] == 'C'){
ROM_GPIOPinWrite(GPIO_PORTK_BASE, GPIO_PIN_2, GPIO_PIN_2);
shell_output("<1>","");
}
if (str[1] == 'D'){
ROM_GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_6, GPIO_PIN_6);
shell_output("<1>","");
}
if (str[1] == 'E'){
ROM_GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_5, GPIO_PIN_5);
shell_output("<1>","");
}
if (str[1] == 'F'){
ROM_GPIOPinWrite(GPIO_PORTJ_BASE, GPIO_PIN_6, GPIO_PIN_6);
shell_output("<1>","");
}
if (str[1] == 'G'){
ROM_GPIOPinWrite(GPIO_PORTR_BASE, GPIO_PIN_5, GPIO_PIN_5);
shell_output("<1>","");
}
if (str[1] == 'H'){
ROM_GPIOPinWrite(GPIO_PORTH_BASE, GPIO_PIN_2, GPIO_PIN_2);
shell_output("<1>","");
}
if (str[1] == 'I'){
ROM_GPIOPinWrite(GPIO_PORTH_BASE, GPIO_PIN_3, GPIO_PIN_3);
shell_output("<1>","");
}
if (str[1] == 'J'){
ROM_GPIOPinWrite(GPIO_PORTH_BASE, GPIO_PIN_6, GPIO_PIN_6);
shell_output("<1>","");
}
}
A GPIO pin is checked with the following code,
static void status(char *str)
{
if (str[1] == '0')
{
if (ROM_GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_6))
{
shell_output("<1>","");
}
else
{
shell_output("<0>","");
}
}
if (str[1] == '1')
{
if (ROM_GPIOPinRead(GPIO_PORTB_BASE, GPIO_PIN_5))
{
shell_output("<1>","");
}
else
{
shell_output("<0>","");
}
}
if (str[1] == '2')
{
if (ROM_GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_4))
{
shell_output("<1>","");
}
else
{
shell_output("<0>","");
}
}
if (str[1] == '3')
{
if (ROM_GPIOPinRead(GPIO_PORTD_BASE, GPIO_PIN_4))
{
shell_output("<1>","");
}
else
{
shell_output("<0>","");
}
}
if (str[1] == '4')
{
if (ROM_GPIOPinRead(GPIO_PORTD_BASE, GPIO_PIN_6))
{
shell_output("<1>","");
}
else
{
shell_output("<0>","");
}
}
if (str[1] == '5')
{
if (ROM_GPIOPinRead(GPIO_PORTD_BASE, GPIO_PIN_1))
{
shell_output("<1>","");
}
else
{
shell_output("<0>","");
}
}
if (str[1] == '6')
{
if (ROM_GPIOPinRead(GPIO_PORTD_BASE, GPIO_PIN_3))
{
shell_output("<1>","");
}
else
{
shell_output("<0>","");
}
}
if (str[1] == '7')
{
if (ROM_GPIOPinRead(GPIO_PORTQ_BASE, GPIO_PIN_1))
{
shell_output("<1>","");
}
else
{
shell_output("<0>","");
}
}
if (str[1] == '8')
{
if (ROM_GPIOPinRead(GPIO_PORTB_BASE, GPIO_PIN_7))
{
shell_output("<1>","");
}
else
{
shell_output("<0>","");
}
}
if (str[1] == '9')
{
if (ROM_GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_2))
{
shell_output("<1>","");
}
else
{
shell_output("<0>","");
}
}
if (str[1] == 'A')
{
if (ROM_GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_1))
{
shell_output("<1>","");
}
else
{
shell_output("<0>","");
}
}
if (str[1] == 'B')
{
if (ROM_GPIOPinRead(GPIO_PORTK_BASE, GPIO_PIN_0))
{
shell_output("<1>","");
}
else
{
shell_output("<0>","");
}
}
if (str[1] == 'C')
{
if (ROM_GPIOPinRead(GPIO_PORTK_BASE, GPIO_PIN_2))
{
shell_output("<1>","");
}
else
{
shell_output("<0>","");
}
}
if (str[1] == 'D')
{
if (ROM_GPIOPinRead(GPIO_PORTC_BASE, GPIO_PIN_6))
{
shell_output("<1>","");
}
else
{
shell_output("<0>","");
}
}
if (str[1] == 'E')
{
if (ROM_GPIOPinRead(GPIO_PORTC_BASE, GPIO_PIN_5))
{
shell_output("<1>","");
}
else
{
shell_output("<0>","");
}
}
if (str[1] == 'F')
{
if (ROM_GPIOPinRead(GPIO_PORTJ_BASE, GPIO_PIN_6))
{
shell_output("<1>","");
}
else
{
shell_output("<0>","");
}
}
if (str[1] == 'G')
{
if (ROM_GPIOPinRead(GPIO_PORTR_BASE, GPIO_PIN_5))
{
shell_output("<1>","");
}
else
{
shell_output("<0>","");
}
}
if (str[1] == 'H')
{
if (ROM_GPIOPinRead(GPIO_PORTH_BASE, GPIO_PIN_2))
{
shell_output("<1>","");
}
else
{
shell_output("<0>","");
}
}
if (str[1] == 'I')
{
if (ROM_GPIOPinRead(GPIO_PORTH_BASE, GPIO_PIN_3))
{
shell_output("<1>","");
}
else
{
shell_output("<0>","");
}
}
if (str[1] == 'J')
{
if (ROM_GPIOPinRead(GPIO_PORTH_BASE, GPIO_PIN_6))
{
shell_output("<1>","");
}
else
{
shell_output("<0>","");
}
}
}
I need to switch GPIO pins on/off as quickly as possible, but it takes about 750 milliseconds to switch.
In the computer I am sending the telnet commands to turn on and off gpio pins via a C# program.
Sending the open or close command without verifying the microcontroller switched correctly will prevent some GPIO pins from turning off/on correctly.
do
{
string close_result1 = cdf_muxes[card].close(channel);
string close_result2 = cdf_muxes[card + 1].close(channel);
if (close_result1.Contains("1")) cr1 = true; else cr1 = false;
if (close_result2.Contains("1")) cr2 = true; else cr2 = false;
} while (!(cr1 == true & cr2 == true));
bool or1 = false;
bool or2 = false;
do
{
string open_result1 = cdf_muxes[card].open(channel);
string open_result2 = cdf_muxes[card + 1].open(channel);
if (open_result1.Contains("0")) or1 = true; else or1 = false;
if (open_result2.Contains("0")) or2 = true; else or2 = false;
} while (!(or1 == true & or2 == true));
Does anyone have any suggestions on how to decrease the amount of time it takes to turn a GPIO pin on/off?
Thanks,
Allan