将libpic30.h与pic32一起使用



现在,我将自己的端口开发到pic32,我需要使用libpic30.h库。我一直在阅读有关它的内容,并寻找相同的库与PIC32(入门套件III PIC32MX450/470 MCU),我认为它不存在。这是正确的?如果存在很棒!

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

在这种情况下,libpic30.h与pic32不合时间吗?我不知道,很好,在这种情况下,最好的方法是最好的方法?...我迷路了!

感谢您的知识!;)

是的,首先您不能使用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.
            }
        }
    }

}

最新更新