Hi there,
i think it should be possible to connect any gpio to another logical gpio.
i use the W1TS and W1TC functions to set and clear the gpio levels.
I have 14 bit values and those values i give out as binary to the gpios.
I do this by clearing all necessary bits with WITC and then calculating the new value with OR and AND and bitshift. Then I set the value .
This all needs time, so i would like to know, if there is a better way.
Could someone tell me, how to logical swap the Pins?
for now i use 4,5,13,14,15,16,17,18,19,21,22,23,26,27 because they are in the same register and not needed to boot.
i do it like this:
uint32_t GPIO_w1ts = GPIO_OUT_W1TS_REG;
uint32_t GPIO_w1tc = GPIO_OUT_W1TC_REG;
uint32_t SetBits (uint16_t bits)
{
return ( (bits & 0b11000000000000)<<14) | ((bits & 0b00111000000000)<<12)|((bits & 00000111111100)<<11) | ((bits & 0b....
}
main:
int counter=1;
while(1)
{
count++;
GPIO_w1tc=0b1100111011111110000000110000; //clear em all
GPIO_w1ts= SetBits(counter);
}
///////////////////////////////////////////////////////////////
Now i would like to use another gpio setting, that i could do the following:
GPIO_w1ts = counter;
You see, i would like to swap the numbers of the logical connected pins.
Also I would like to know, if there is a way to set a value without resetting the register.
Sorry for my bad english!
GPIO mux routing
-
- Posts: 3
- Joined: Wed Aug 23, 2017 4:28 pm
GPIO mux routing
Last edited by RLauersdorf on Fri Sep 22, 2017 12:47 pm, edited 1 time in total.
-
- Posts: 9708
- Joined: Thu Nov 26, 2015 4:08 am
Re: GPIO mux crouting
Sorry, the hardware doesn't really have any tricks you can do here... I fear that your implementation is pretty optimal already. The bitshifts shouldn't take too much time, however; the Xtensa architecture has dedicated instructions for that. If you really want something faster, you can try spending some memory on a lookup table in RAM to go from counter value to GPIO-mask; that makes the runtime conversion into just a lookup in that table.
-
- Posts: 3
- Joined: Wed Aug 23, 2017 4:28 pm
Re: GPIO mux routing
Thank you ESP_Sprite!
Somehow my first post disappeared after correcting some words. So I repost it again with some added text::
/////////////->->->
Hi there,
i think it should be possible to connect any gpio to another logical gpio.
i use the W1TS and W1TC functions to set and clear the gpio levels.
I have 14 bit values and those values i give out as binary to the gpios.
I do this by clearing all necessary bits with WITC and then calculating the new value with OR and AND and bitshift. Then I set the value .
This all needs time, so i would like to know, if there is a better way.
Could someone tell me, how to logical swap the Pins?
for now i use 4,5,13,14,15,16,17,18,19,21,22,23,26,27 because they are in the same register and not needed to boot.
i do it like this:
uint32_t* GPIO_w1ts = GPIO_OUT_W1TS_REG;
uint32_t* GPIO_w1tc = GPIO_OUT_W1TC_REG;
uint32_t SetBits (uint16_t bits)
{
return ( (bits & 0b11000000000000)<<14) | ((bits & 0b00111000000000)<<12)|((bits & 00000111111100)<<11) | ((bits & 0b....
}
main:
int counter=0;
while(1)
{
counter++;
*GPIO_w1tc=0b1100111011111110000000110000; //clear em all
*GPIO_w1ts= SetBits(counter);
}
///////////////////////////////////////////////////////////////
Now i would like to use another gpio setting, that i could do the following:
GPIO_w1ts = counter;
You see, i would like to swap the numbers of the logical connected pins.
Also I would like to know, if there is a way to set a value without resetting the register.
I have now figured out, that there is also a register that can be used to direct communicate with the output pins.
it seems, that if i only write a value in a
///////////////////////////////////////
uint32_t* GPIO_w1t = GPIO_OUT_REG;
while(1)
{
*GPIO_w1t = 0b1100111011111110000000110000;
}
///////////////////////////////////////
i get an output.
this blink-code is also working:
///////////////////////////////////////
uint32_t* GPIO_w1t = GPIO_OUT_REG;
while(1)
{
*GPIO_w1t = 0b1100111011111110000000110000;
vTaskDelay(1000 / portTICK_RATE_MS);
*GPIO_w1t = 0
vTaskDelay(1000 / portTICK_RATE_MS);
}
///////////////////////////////////////
,...but when i try to measure the output frequency by doing:
///////////////////////////////////////
uint32_t* GPIO_w1t = GPIO_OUT_REG;
while(1)
{
*GPIO_w1t = 0b1100111011111110000000110000;
*GPIO_w1t = 0;
}
///////////////////////////////////////
every output-pins stays 0V,...
i think, that using GPIO_OUT_REG could save the µc some time, but somehow it seems a bit tricky.
it seems to be "not atomic" as people call it.
I could not figure out, if the "not atomic" behavior means what i see on my desc.
Thought it would mean, that it needs not always the same amount of time.
Could someone explain me please?
Now i do it like
////////////////
*GPIO_w1tc = 0b1100111011111110000000110000 & (~(BitShiftedValue));
*GPIO_w1ts = BitShiftedValue;
///////////////
Sorry for my bad english!
Somehow my first post disappeared after correcting some words. So I repost it again with some added text::
/////////////->->->
Hi there,
i think it should be possible to connect any gpio to another logical gpio.
i use the W1TS and W1TC functions to set and clear the gpio levels.
I have 14 bit values and those values i give out as binary to the gpios.
I do this by clearing all necessary bits with WITC and then calculating the new value with OR and AND and bitshift. Then I set the value .
This all needs time, so i would like to know, if there is a better way.
Could someone tell me, how to logical swap the Pins?
for now i use 4,5,13,14,15,16,17,18,19,21,22,23,26,27 because they are in the same register and not needed to boot.
i do it like this:
uint32_t* GPIO_w1ts = GPIO_OUT_W1TS_REG;
uint32_t* GPIO_w1tc = GPIO_OUT_W1TC_REG;
uint32_t SetBits (uint16_t bits)
{
return ( (bits & 0b11000000000000)<<14) | ((bits & 0b00111000000000)<<12)|((bits & 00000111111100)<<11) | ((bits & 0b....
}
main:
int counter=0;
while(1)
{
counter++;
*GPIO_w1tc=0b1100111011111110000000110000; //clear em all
*GPIO_w1ts= SetBits(counter);
}
///////////////////////////////////////////////////////////////
Now i would like to use another gpio setting, that i could do the following:
GPIO_w1ts = counter;
You see, i would like to swap the numbers of the logical connected pins.
Also I would like to know, if there is a way to set a value without resetting the register.
I have now figured out, that there is also a register that can be used to direct communicate with the output pins.
it seems, that if i only write a value in a
///////////////////////////////////////
uint32_t* GPIO_w1t = GPIO_OUT_REG;
while(1)
{
*GPIO_w1t = 0b1100111011111110000000110000;
}
///////////////////////////////////////
i get an output.
this blink-code is also working:
///////////////////////////////////////
uint32_t* GPIO_w1t = GPIO_OUT_REG;
while(1)
{
*GPIO_w1t = 0b1100111011111110000000110000;
vTaskDelay(1000 / portTICK_RATE_MS);
*GPIO_w1t = 0
vTaskDelay(1000 / portTICK_RATE_MS);
}
///////////////////////////////////////
,...but when i try to measure the output frequency by doing:
///////////////////////////////////////
uint32_t* GPIO_w1t = GPIO_OUT_REG;
while(1)
{
*GPIO_w1t = 0b1100111011111110000000110000;
*GPIO_w1t = 0;
}
///////////////////////////////////////
every output-pins stays 0V,...
i think, that using GPIO_OUT_REG could save the µc some time, but somehow it seems a bit tricky.
it seems to be "not atomic" as people call it.
I could not figure out, if the "not atomic" behavior means what i see on my desc.
Thought it would mean, that it needs not always the same amount of time.
Could someone explain me please?
Now i do it like
////////////////
*GPIO_w1tc = 0b1100111011111110000000110000 & (~(BitShiftedValue));
*GPIO_w1ts = BitShiftedValue;
///////////////
Sorry for my bad english!
Who is online
Users browsing this forum: Bing [Bot] and 96 guests