The use of the ESP8266 in the world of IoT

User avatar
By scargill
#11810 I am having the most immense difficulty with PORTS - no doubt due to an utter mis-understanding.
I'm using the ESP-12 which has most of the ports brought out - including 3,4,12,13,14

I need to use the MACRO version of the port on-off control as I need precise speed for controlling serial LEDS

WRITE_PERI_REG( PERIPHS_GPIO_BASEADDR + GPIO_ID_PIN(WSGPIO), 1 );
WRITE_PERI_REG( PERIPHS_GPIO_BASEADDR + GPIO_ID_PIN(WSGPIO), 0 );

Assuming WSGPIO is 0 - I can turn GPIO0 on and off no problem - but I want to control GPIO12.

WRITE_PERI_REG( PERIPHS_GPIO_BASEADDR + GPIO_ID_PIN(12), 1 );
WRITE_PERI_REG( PERIPHS_GPIO_BASEADDR + GPIO_ID_PIN(12), 0 );

That DOESN'T WORK

WRITE_PERI_REG( PERIPHS_GPIO_BASEADDR, 0x1000 );
WRITE_PERI_REG( PERIPHS_GPIO_BASEADDR , 0 );

THat DOES work but it messes the OTHER port bits up.

I've also tried

WRITE_PERI_REG( PERIPHS_GPIO_BASEADDR + GPIO_ID_PIN(12), 0x1000 );
WRITE_PERI_REG( PERIPHS_GPIO_BASEADDR + GPIO_ID_PIN(12), 0 );

That doesn't work.

So can someone tell me - what the correct values are to control port GPIO12 - without messing up the other ports?

(all assuming the ports are set up as outputs in the first place and tested as outputs - which they are).

Pete.
User avatar
By HolgerW
#11812 Hi, i use this macros (see gpio.h)
Code: Select allGPIO_OUTPUT_SET(12, 1);
GPIO_OUTPUT_SET(12, 0);

or
Code: Select allgpio_output_set(0, BIT12, BIT12, 0); // set to 0
gpio_output_set(BIT12, 0, BIT12, 0); // set to 1


Holger
User avatar
By scargill
#11819 Thanks for that but it messes the timings up - the maths must be different or the compiler is handling it differently..

So does anyone know the exact equivalent for this - (GPIO-0) for GPIO-12)

WRITE_PERI_REG( PERIPHS_GPIO_BASEADDR + GPIO_ID_PIN(WSGPIO), 1 );
WRITE_PERI_REG( PERIPHS_GPIO_BASEADDR + GPIO_ID_PIN(WSGPIO), 0 );


Thanks

Pete.
User avatar
By mariuszb
#12650
scargill wrote:Thanks for that but it messes the timings up - the maths must be different or the compiler is handling it differently..

So does anyone know the exact equivalent for this - (GPIO-0) for GPIO-12)

WRITE_PERI_REG( PERIPHS_GPIO_BASEADDR + GPIO_ID_PIN(WSGPIO), 1 );
WRITE_PERI_REG( PERIPHS_GPIO_BASEADDR + GPIO_ID_PIN(WSGPIO), 0 );


Thanks

Pete.



first:
#define PIN12_MUX PERIPHS_IO_MUX_MTDI_U
#define PIN12_FUNC FUNC_GPIO12
#define PIN12_PIN 12

next:
PIN_FUNC_SELECT(PIN12_MUX, PIN12_FUNC);
PIN_PULLUP_EN(PIN12_MUX);

and next:
GPIO_OUTPUT_SET(PIN12_PIN, 1);
or
GPIO_OUTPUT_SET(PIN12_PIN, 0);


for reading:
GPIO_DIS_OUTPUT(PIN12_PIN);
if GPIO_INPUT_GET(PIN12_PIN) == .......