STM32时机ULPI接口 [英] stm32 timing ULPI interface

查看:3468
本文介绍了STM32时机ULPI接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个项目,我需要用USB PHY芯片进行通信。我使用的是STM32 microcontoller。 (stm32f446ret6,的http://www.st.com/web/en/resource/technical/document/datasheet/DM00141306.pdf)

要在 USB PHY 芯片沟通,我需要使用 ULPI接口。这是一并行通信。此接口为60MHz的clockfrequenty。

我的 STM32控制器的频率 180MHz的的(他的最大的,我查了一下这两次)。所以对于ULPI接口的每一个时钟脉冲,单片机有3个时钟脉冲。

要使用USB-PHY芯片的沟通,我需要首先让设备知道,巫寄存器我想调整。当USB-PHY芯片接收到该命令好,他会设置NXT行高。

ULPI时序

我觉得这是我的问题。我需要检查或者这是高(offcourse使用if语句)。而这正是我的问题是,我想。难道if语句需要很多时钟周期?有没有办法解决这个问题?

我的code:

 布尔UPLI_setRegister_FunctionControl(无效)
{    如果((GPIOA - >&IDR放大器; 0×01)){//检查DIR高
        返回false;
    }其他{
        GPIOB - > ODR = 4;
        // INT J = 0;        如果((GPIOA - > IDR及(uint16_t)×0020)){//等到NXT控制线为高
            GPIOB - > ODR = 0b0000000001000000;
            / *
            注册设置
            LMP让 - > 0
            SuspendM - > 1
            复位 - > 0
            OPMODE - > 00
            TermSelect - > 0
            XcrvSelect - > 00
            * /            如果(GPIOA - > IDR及(uint16_t)×0020){
                // NXT仍然很高
                GPIOA - > ODR | = 0×0002; // STP高
                的for(int i = 0;我== 1;我++); //浪费一些时间
                //设置输出回0;
                GPIOB - > ODR = 0×0000;
                GPIOA - > ODR = 0×0000;
                返回true;
            }其他{
                GPIOA - > ODR | = 0×0002; // STP高
                的for(int i = 0;我== 1;我++); //浪费一些时间
                GPIOB - > ODR = 0x0000000;
                GPIOA - > ODR = 0x000000处;
                返回false;
            }
        }        其他{
            GPIOA - > ODR | = 0×0002; // STP高
            的for(int i = 0;我== 1;我++); //浪费一些时间
            GPIOB - > ODR = 0x0000000;
            GPIOA - > ODR = 0x000000处;
            返回false;
        }
    }}


解决方案

您需要使用您的微控制器的USB_HS外设与此硬件交互,而不是它的GPIO。该GPIO都没有能力满足时序要求。

在硬件接口上的信息,在第35章(OTG_HS)提供的的STM32F4参考手册,以及从ST其他文档。

I'm working on a project where I need to communicate with an USB PHY chip. I am using a STM32 microcontoller. (stm32f446ret6, http://www.st.com/web/en/resource/technical/document/datasheet/DM00141306.pdf)

To communicate with the USB PHY chip, I need to use the ULPI interface. This is an parallel communication. This interface has a clockfrequenty of 60MHz.

The frequency of my STM32-controller is 180MHz(his maximum, I checked this twice). So for every clock pulse of the ULPI interface, the microcontroller had 3 clockpulses.

To communicate with the USB-PHY chip, I need first to let the device know, witch register I want to adjust. When the USB-PHY chip received this command good, he will set the NXT line high.

I think this is my problem. I need to check or this is high (offcourse with an if-statement). And that is where my problem is, I think. Is it possible that the if-statement takes to many clock-cycles? Is there a way to fix this problem?

My code:

bool UPLI_setRegister_FunctionControl(void)
{

    if( (GPIOA -> IDR & 0x01)) {//check if the dir is high
        return false;
    } else {
        GPIOB -> ODR = 4;
        //int j =0;

        if((GPIOA -> IDR & (uint16_t)0x0020)) { // wait until the nxt control line is high
            GPIOB -> ODR = 0b0000000001000000;
            /*
            Register settings
            LMP enable -> 0
            SuspendM -> 1
            Reset -> 0
            Opmode -> 00
            TermSelect -> 0
            XcrvSelect -> 00
            */

            if(GPIOA -> IDR & (uint16_t)0x0020) {
                //NXT still high
                GPIOA ->ODR |= 0x0002; //stp high
                for(int i =0; i==1; i++); //waste some time
                //set outputs back to 0;
                GPIOB -> ODR = 0x0000;
                GPIOA ->ODR = 0x0000;
                return true;
            } else {
                GPIOA ->ODR |= 0x0002; //stp high
                for(int i =0; i==1; i++); //waste some time
                GPIOB -> ODR = 0x0000000;
                GPIOA ->ODR = 0x000000;
                return false;
            }
        }

        else {
            GPIOA ->ODR |= 0x0002; //stp high
            for(int i =0; i==1; i++); //waste some time
            GPIOB -> ODR = 0x0000000;
            GPIOA ->ODR = 0x000000;
            return false;
        }
    }

}

解决方案

You need to use your microcontroller's USB_HS peripheral to interact with this hardware, not its GPIOs. The GPIOs will be incapable of meeting timing requirements.

Information on the hardware interface is available in chapter 35 ("OTG_HS") of the STM32F4 reference manual, as well as in other documentation from ST.

这篇关于STM32时机ULPI接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆