32K_XP(GPIO32) and 32K_XN(GPIO33) pins used for MDC and MDIO pins

colman
Posts: 37
Joined: Mon May 30, 2016 7:41 am

32K_XP(GPIO32) and 32K_XN(GPIO33) pins used for MDC and MDIO pins

Postby colman » Fri Mar 10, 2017 10:15 am

I try to use 32K_XP(GPIO32) for EMAC MDC and 32K_XN(GPIO33) for EMAC MDIO pin without success. GPIO32 always in HiZ state, and GPIO33has bus contention(cannot reach logic 0) in outputing a negative pulse. Below is my code:

#define MDC_PIN_NUM 32
#define MDIO_PIN_NUM 33

//mdc to gpio32
gpio_pad_select_gpio(MDC_PIN_NUM);
gpio_matrix_out(MDC_PIN_NUM, EMAC_MDC_O_IDX, 0, 0);
//mdio to gpio33
gpio_pad_select_gpio(MDIO_PIN_NUM);
gpio_matrix_out(MDIO_PIN_NUM, EMAC_MDO_O_IDX, 0, 0);
gpio_matrix_in(MDIO_PIN_NUM, EMAC_MDI_I_IDX, 0);

Are there something special for these two pins? Or these two pins cannot be used in this way? I have almost used up all the GPIOs and I have to use two pins for slow speed in/out signals.

Regards,
Colman

User avatar
rudi ;-)
Posts: 1698
Joined: Fri Nov 13, 2015 3:25 pm

Re: 32K_XP(GPIO32) and 32K_XN(GPIO33) pins used for MDC and MDIO pins

Postby rudi ;-) » Fri Mar 10, 2017 2:15 pm

colman wrote:
Are there something special for these two pins? Or these two pins cannot be used in this way? I have almost used up all the GPIOs and I have to use two pins for slow speed in/out signals.
please look in pin list PIN NAME is your friend:
there stand as PIN Name
32K_XP
32K_XN
and as FUNCTION1
GPIO32
GPIO33

you need first to clear the base bits if you want to use the GPIO32 and GPIO33 as the general GPIO

Code: Select all

REG_CLR_BIT(RTC_IO_XTAL_32K_PAD_REG, RTC_IO_X32P_MUX_SEL); /* gpio32 route to digital io_mux */
REG_CLR_BIT(RTC_IO_XTAL_32K_PAD_REG, RTC_IO_X32N_MUX_SEL); /* gpio33 route to digital io_mux */
and then you can route like you need the gpio

Code: Select all


#define PIN_SMI_MDC   32 
#define PIN_SMI_MDIO  33


   //mdc to gpio32
    gpio_matrix_out(PIN_SMI_MDC, EMAC_MDC_O_IDX, 0, 0);
    
    //mdio to gpio33
    gpio_matrix_out(PIN_SMI_MDIO, EMAC_MDO_O_IDX, 0, 0);
    gpio_matrix_in(PIN_SMI_MDIO, EMAC_MDI_I_IDX, 0);

best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

colman
Posts: 37
Joined: Mon May 30, 2016 7:41 am

Re: 32K_XP(GPIO32) and 32K_XN(GPIO33) pins used for MDC and MDIO pins

Postby colman » Sat Mar 11, 2017 1:52 am

Dear Rudi,

Thank you very much. The MDC and MDIO seems working, but the MDIO value always read "0" even the waveform shown on the oscilloscope is correct. It seems the MDIO value on the physical pin cannot reach the SMI section of the EMAC.

Regards,
Colman

colman
Posts: 37
Joined: Mon May 30, 2016 7:41 am

Re: 32K_XP(GPIO32) and 32K_XN(GPIO33) pins used for MDC and MDIO pins

Postby colman » Sat Mar 11, 2017 4:27 am

Dear Rudi,

I finally get it work, it need a "gpio_set_direction(PIN_SMI_MDIO, GPIO_MODE_INPUT);" to make the input working.

Regards,
Colman.

User avatar
rudi ;-)
Posts: 1698
Joined: Fri Nov 13, 2015 3:25 pm

Re: 32K_XP(GPIO32) and 32K_XN(GPIO33) pins used for MDC and MDIO pins

Postby rudi ;-) » Sat Mar 11, 2017 6:07 am

colman wrote:Dear Rudi,

I finally get it work, it need a "gpio_set_direction(PIN_SMI_MDIO, GPIO_MODE_INPUT);" to make the input working.

Regards,
Colman.
hi colman

thank you for your friendly feedback
sry for requestion:

after

Code: Select all

//mdio to gpio33
    gpio_matrix_out(PIN_SMI_MDIO, EMAC_MDO_O_IDX, 0, 0);
    gpio_matrix_in(PIN_SMI_MDIO, EMAC_MDI_I_IDX, 0);
you did append

Code: Select all

gpio_set_direction(PIN_SMI_MDIO, GPIO_MODE_INPUT);
for final working MDIO on gpio33?

usually ( normal ) the gpio_matrix_out, gpio_matrix_in do this job by set the output BIT and input BIT in the PIN Mask

ok. i try to reproduce this. thank you for your feedback.

best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

colman
Posts: 37
Joined: Mon May 30, 2016 7:41 am

Re: 32K_XP(GPIO32) and 32K_XN(GPIO33) pins used for MDC and MDIO pins

Postby colman » Mon Mar 13, 2017 2:10 am

Dear Rudi,

Yes, I need to append gpio_set_direction(PIN_SMI_MDIO, GPIO_MODE_INPUT) in order to make it work.

Regards,
Colman

User avatar
rudi ;-)
Posts: 1698
Joined: Fri Nov 13, 2015 3:25 pm

Re: 32K_XP(GPIO32) and 32K_XN(GPIO33) pins used for MDC and MDIO pins

Postby rudi ;-) » Mon Mar 13, 2017 10:52 am

colman wrote:Dear Rudi,

Yes, I need to append gpio_set_direction(PIN_SMI_MDIO, GPIO_MODE_INPUT) in order to make it work.

Regards,
Colman
hi colman
thank you for your reply

can u say me plz, which modul you use?

best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

colman
Posts: 37
Joined: Mon May 30, 2016 7:41 am

Re: 32K_XP(GPIO32) and 32K_XN(GPIO33) pins used for MDC and MDIO pins

Postby colman » Tue Mar 14, 2017 7:11 am

I am using a custom made PCB, not using module.

Colman

User avatar
rudi ;-)
Posts: 1698
Joined: Fri Nov 13, 2015 3:25 pm

Re: 32K_XP(GPIO32) and 32K_XN(GPIO33) pins used for MDC and MDIO pins

Postby rudi ;-) » Wed Mar 15, 2017 4:12 pm

colman wrote:I am using a custom made PCB, not using module.

Colman
thank you.
in theme cause set pin extra to input
have asked for, honest, i do not understand this double separate set
it looks like we need to set FUNC things in the FUNC Reg
that know, MDIO is out and input
and if we use other pins that are not Function pins
we must say the input mode separatly too
( why not output too ? - honest i do not know )

have a look here

best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

metinkiyak
Posts: 1
Joined: Sun Jul 10, 2022 12:49 pm

Re: 32K_XP(GPIO32) and 32K_XN(GPIO33) pins used for MDC and MDIO pins

Postby metinkiyak » Sun Jul 10, 2022 12:55 pm

Hi, i'm searching gpio32 and gpio33 how can i use input? i try many code example but i cant fix it. are you help me please?

#include <Adafruit_SSD1306.h>
#include <SoftwareSerial.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
//Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, 0, 1, -1);

#define PIN_SMI_MDC 32
#define PIN_SMI_MDIO 33


bool buttonDown = 0, buttonUp = 0, buttonOk = 0, buttonBack=0;


//void aPinMode(int pinNum, int pinDir) {
// // Enable GPIO32 or 33 as output.
// if (pinNum == 32 || pinNum == 33) {
// uint64_t gpioBitMask = (pinNum == 32) ? 1ULL << GPIO_NUM_32 : 1ULL << GPIO_NUM_33;
// gpio_mode_t gpioMode = (pinDir == INPUT) ? GPIO_MODE_OUTPUT : GPIO_MODE_INPUT;
// gpio_config_t io_conf;
// io_conf.intr_type = GPIO_INTR_DISABLE;
// io_conf.mode = gpioMode;
// io_conf.pin_bit_mask = gpioBitMask;
// io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
// io_conf.pull_up_en = GPIO_PULLUP_DISABLE;
// gpio_config(&io_conf);
// } else pinMode(pinNum, pinDir);
//}


void setup() {

REG_CLR_BIT(RTC_IO_XTAL_32K_PAD_REG, RTC_IO_X32P_MUX_SEL); /* gpio32 route to digital io_mux */
REG_CLR_BIT(RTC_IO_XTAL_32K_PAD_REG, RTC_IO_X32N_MUX_SEL); /* gpio33 route to digital io_mux */

gpio_matrix_in(PIN_SMI_MDC, EMAC_MDC_O_IDX, 0);
gpio_matrix_in(PIN_SMI_MDIO, EMAC_MDI_I_IDX, 0);

//gpio_set_direction(PIN_SMI_MDC, GPIO_MODE_INPUT);
//gpio_set_direction(PIN_SMI_MDIO, GPIO_MODE_INPUT);

// I2C Init
Wire.begin(5,18); //SDA, SCL
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.println("Welcome!");
display.display();

pinMode(buttonUp, INPUT);
pinMode(buttonDown, INPUT);
pinMode(buttonOk, INPUT);
pinMode(buttonBack, INPUT);

}


void loop() {
buttonDown = digitalRead(32);
buttonUp = digitalRead(33);
buttonOk = digitalRead(27);
buttonBack = digitalRead(14);

if(buttonDown == HIGH){
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.println("up active");
display.display();
}

if(buttonUp == HIGH){
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.println("down active");
display.display();
}


if(buttonOk == HIGH){
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.println("ok active");
display.display();
}


if(buttonBack == HIGH){
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.println("back active");
display.display();
}

}

Who is online

Users browsing this forum: Google [Bot] and 58 guests