2

现在我正在开发自己的 PIC32 端口,我需要使用 libpic30.h 库。我一直在阅读它并寻找与 PIC32(入门套件 III PIC32MX450/470 MCU)相同的库,但我认为它不存在。这是正确的?如果它存在那就太好了!

libpic30.h 代码: https ://code.google.com/p/uavfirmware/source/browse/UAVFirmware/include/libpic30.h?r=1db3ec8e9015efb837b0d684c98204317ea2efd5

在这种情况下,libpic30.h 与 PIC32 不兼容,对吧?我不知道,很好,在这种情况下如何做这个端口的最好方法是什么?......我很迷茫!

谢谢你的知识!!;)

4

1 回答 1

1

是的,首先你不能使用 libpic30.h。编译器不应该让你轻易使用它。您将需要使用 xc.h 并按照相应的 PIC32 器件进行操作。我不确定延迟功能在哪里,但那里有一个接近你想要的地方。如果找不到。在 Tick.c 中查找 TCP/IP 遗留库,其中有 32 位设备的书面延迟。

void SSTDelay10us(U32 tenMicroSecondCounter)
{
    volatile S32 cyclesRequiredForEntireDelay;
    int clock;
    clock = 80000000;

    if (clock <= 500000) //for all FCY speeds under 500KHz (FOSC <= 1MHz)
    {
        //10 cycles burned through this path (includes return to caller).
        //For FOSC == 1MHZ, it takes 5us.
        //For FOSC == 4MHZ, it takes 0.5us
        //For FOSC == 8MHZ, it takes 0.25us.
        //For FOSC == 10MHZ, it takes 0.2us.
    }
    else
    {
        //7 cycles burned to this point.
        //We want to pre-calculate number of cycles required to delay 10us *  
        // tenMicroSecondCounter using a 1 cycle granule.
        cyclesRequiredForEntireDelay = (S32)(clock / 100000) * tenMicroSecondCounter;
        //We subtract all the cycles used up until we reach the 
        //while loop below, where each loop cycle count is subtracted.
        //Also we subtract the 5 cycle function return.
        cyclesRequiredForEntireDelay -= 24; //(19 + 5)
        if (cyclesRequiredForEntireDelay <= 0)
        {
            // If we have exceeded the cycle count already, bail!
        }
        else
        {
            while (cyclesRequiredForEntireDelay > 0) //19 cycles used to this point.
            {
                cyclesRequiredForEntireDelay -= 8; //Subtract cycles burned while doing each delay stage, 8 in this case.
            }
        }
    }

}

于 2015-05-08T23:01:15.010 回答