cuishuang456
Member
Hello everyone,
I need some help to make the digital outputs a bit faster. I need to use T40 to generate a clock somewhere between 10-25 MHz on pin 20 and 21.
I tried to increase the drive strength, as well as play with IOMUXC_PAD_SRE and IOMUXC_PAD_SPEED. (I modified Paul's pinModeExt code). Changing OUTPUT_1 to OUTPUT_7 make the raise time change, but I don't see any effect on IOMUXC_PAD_SRE and IOMUXC_PAD_SPEED. With OUTPUT_7, I see the raise time is about 40ns on Pin 21. Is this the fastest I can get?
I'm trying to make my own I2S code to drive Audio Codecs, currently the clock looks very slow and will definitly loose timing if I try to drive it faster.
I have attahced a photo from my 200Mhz scope. The scope is connected directly to the pin of a unsoldered T40. Nothing is connected to it.
Thank you!
pinModeExt(20, OUTPUT_7);
pinModeExt(21, OUTPUT_7);
void pinModeExt(uint8_t pin, uint8_t mode)
{
const struct digital_pin_bitband_and_config_table_struct *p;
if (pin >= CORE_NUM_DIGITAL) return;
p = digital_pin_to_info_PGM + pin;
const uint32_t base_pad_flags = IOMUXC_PAD_SRE | IOMUXC_PAD_SPEED(3);
if (mode == OUTPUT || mode == OUTPUT_OPENDRAIN || (mode >= OUTPUT_1 && mode <= OUTPUT_7))
{
*(p->reg + 1) |= p->mask; // TODO: atomic
if (mode == OUTPUT) // Default
{
*(p->pad) = base_pad_flags | IOMUXC_PAD_DSE(7);
}
else if (mode == OUTPUT_1)
{
*(p->pad) = base_pad_flags | IOMUXC_PAD_DSE(1);
}
else if (mode == OUTPUT_2)
{
*(p->pad) = base_pad_flags | IOMUXC_PAD_DSE(2);
}
else if (mode == OUTPUT_3)
{
*(p->pad) = base_pad_flags | IOMUXC_PAD_DSE(3);
}
else if (mode == OUTPUT_4)
{
*(p->pad) = base_pad_flags | IOMUXC_PAD_DSE(4);
}
else if (mode == OUTPUT_5)
{
*(p->pad) = base_pad_flags | IOMUXC_PAD_DSE(5);
}
else if (mode == OUTPUT_6)
{
*(p->pad) = base_pad_flags | IOMUXC_PAD_DSE(6);
}
else if (mode == OUTPUT_7)
{
*(p->pad) = base_pad_flags | IOMUXC_PAD_DSE(7);
}
else // OUTPUT_OPENDRAIN
{
*(p->pad) = base_pad_flags | IOMUXC_PAD_DSE(7) | IOMUXC_PAD_ODE;
}
}
else
{
*(p->reg + 1) &= ~(p->mask); // TODO: atomic
if (mode == INPUT)
{
*(p->pad) = base_pad_flags | IOMUXC_PAD_DSE(7);
}
else if (mode == INPUT_PULLUP)
{
*(p->pad) = base_pad_flags | IOMUXC_PAD_DSE(7) | IOMUXC_PAD_PKE |
IOMUXC_PAD_PUE | IOMUXC_PAD_PUS(3) | IOMUXC_PAD_HYS;
}
else if (mode == INPUT_PULLDOWN)
{
*(p->pad) = base_pad_flags | IOMUXC_PAD_DSE(7) | IOMUXC_PAD_PKE |
IOMUXC_PAD_PUE | IOMUXC_PAD_PUS(0) | IOMUXC_PAD_HYS;
}
else // INPUT_DISABLE
{
*(p->pad) = base_pad_flags | IOMUXC_PAD_DSE(7) | IOMUXC_PAD_HYS;
}
}
*(p->mux) = 5 | 0x10;
}
I need some help to make the digital outputs a bit faster. I need to use T40 to generate a clock somewhere between 10-25 MHz on pin 20 and 21.
I tried to increase the drive strength, as well as play with IOMUXC_PAD_SRE and IOMUXC_PAD_SPEED. (I modified Paul's pinModeExt code). Changing OUTPUT_1 to OUTPUT_7 make the raise time change, but I don't see any effect on IOMUXC_PAD_SRE and IOMUXC_PAD_SPEED. With OUTPUT_7, I see the raise time is about 40ns on Pin 21. Is this the fastest I can get?
I'm trying to make my own I2S code to drive Audio Codecs, currently the clock looks very slow and will definitly loose timing if I try to drive it faster.
I have attahced a photo from my 200Mhz scope. The scope is connected directly to the pin of a unsoldered T40. Nothing is connected to it.
Thank you!
pinModeExt(20, OUTPUT_7);
pinModeExt(21, OUTPUT_7);
void pinModeExt(uint8_t pin, uint8_t mode)
{
const struct digital_pin_bitband_and_config_table_struct *p;
if (pin >= CORE_NUM_DIGITAL) return;
p = digital_pin_to_info_PGM + pin;
const uint32_t base_pad_flags = IOMUXC_PAD_SRE | IOMUXC_PAD_SPEED(3);
if (mode == OUTPUT || mode == OUTPUT_OPENDRAIN || (mode >= OUTPUT_1 && mode <= OUTPUT_7))
{
*(p->reg + 1) |= p->mask; // TODO: atomic
if (mode == OUTPUT) // Default
{
*(p->pad) = base_pad_flags | IOMUXC_PAD_DSE(7);
}
else if (mode == OUTPUT_1)
{
*(p->pad) = base_pad_flags | IOMUXC_PAD_DSE(1);
}
else if (mode == OUTPUT_2)
{
*(p->pad) = base_pad_flags | IOMUXC_PAD_DSE(2);
}
else if (mode == OUTPUT_3)
{
*(p->pad) = base_pad_flags | IOMUXC_PAD_DSE(3);
}
else if (mode == OUTPUT_4)
{
*(p->pad) = base_pad_flags | IOMUXC_PAD_DSE(4);
}
else if (mode == OUTPUT_5)
{
*(p->pad) = base_pad_flags | IOMUXC_PAD_DSE(5);
}
else if (mode == OUTPUT_6)
{
*(p->pad) = base_pad_flags | IOMUXC_PAD_DSE(6);
}
else if (mode == OUTPUT_7)
{
*(p->pad) = base_pad_flags | IOMUXC_PAD_DSE(7);
}
else // OUTPUT_OPENDRAIN
{
*(p->pad) = base_pad_flags | IOMUXC_PAD_DSE(7) | IOMUXC_PAD_ODE;
}
}
else
{
*(p->reg + 1) &= ~(p->mask); // TODO: atomic
if (mode == INPUT)
{
*(p->pad) = base_pad_flags | IOMUXC_PAD_DSE(7);
}
else if (mode == INPUT_PULLUP)
{
*(p->pad) = base_pad_flags | IOMUXC_PAD_DSE(7) | IOMUXC_PAD_PKE |
IOMUXC_PAD_PUE | IOMUXC_PAD_PUS(3) | IOMUXC_PAD_HYS;
}
else if (mode == INPUT_PULLDOWN)
{
*(p->pad) = base_pad_flags | IOMUXC_PAD_DSE(7) | IOMUXC_PAD_PKE |
IOMUXC_PAD_PUE | IOMUXC_PAD_PUS(0) | IOMUXC_PAD_HYS;
}
else // INPUT_DISABLE
{
*(p->pad) = base_pad_flags | IOMUXC_PAD_DSE(7) | IOMUXC_PAD_HYS;
}
}
*(p->mux) = 5 | 0x10;
}