错误信息:找不到外设的引脚图 位置:Nucleo-F429ZI上的0x8009B0B 0x8009B0B在Nucleo-F429ZI上。

问题描述 投票:0回答:1

当我把这个加载到我的板子上时,我得到一个pinmap not found for peripheral的错误。我对这个问题做了一些研究 (我访问的其中一个网页)我想我明白了这个问题,但是我使用的引脚都支持我要求它们做的事情。这个问题只是在我把我的代码从程序化转换为面向对象后才出现的(我需要这样做才能正确实现调度)。

我感觉这与我在构造函数成员初始化列表中初始化它们的方式有关,因为我不完全理解它是如何工作的(我对C++相当陌生)。

我的程序还有其他的类,但是它们的结构和我的UpdateOutput类一样。

先谢谢你的任何建议。

int main() {
    printf("inside main");

    DigitalOut led1(LED1);
    AnalogOut Vout(A0);
    UpdateOutput wave;
    SensorData inputs;
    Timer time;

    enum waves {OFF = 0, SINE, TRIANGLE, SAW, SQUARE};
    int waveType = OFF;

    float sonarCorrection = inputs.calibrateSonar();//makes a measurement of the acatual run time of the sonar code
    float topFrequency = 1047.0f;                                       //the highest frequency the synth will play
    float upperSonarThreshold = 1000.0f;                        //the furthest distance the sonar will register
    float lowerSonarThreshold = 100.0f;                         //the closest distance the sonar will measure
    float period = 2272.73f; 
    //replace with:
    //float period = inputs.getFrequency(float lowerThreshold, float upperThreshold, int correction, float topFrequency);
    //after bug fixes have been applied

    led1 = 1;                   //turn on led1 to show code is running properly

    time.reset();
    time.start();
    int tmr = time.read_us();

    //test loop before thredding is applied
    while(true)
    {
        waveType = SINE; //keep synth producing a sine wave for testing
        tmr = time.read_us();
        switch(waveType)
        {
            case OFF:
                Vout = 0.0f;
                break;

            case SINE:
                Vout = wave.sinWave(tmr , period);
                break;

            case TRIANGLE:
                Vout = wave.triangleWave(tmr , period);
                break;

            case SAW:
                    Vout = wave.sawWave(tmr, period);
                break;

            case SQUARE:
                Vout = wave.squareWave(tmr, period);
                break;

            default:
                waveType = TRIANGLE;
                break;


        }//end of wave type switch case
    }

}

更新输出类。

class UpdateOutput{


    public:


            //constructor for class, with member initializer list
                UpdateOutput(): runLed(LED2), clipLed(LED3), dac(D13) 
                {}

            float sinWave(int tmr, float period);

            float sawWave(int tmr, float period);

            float triangleWave(int tmr, float period);

            float squareWave(int tmr, float period);


    private:

    //class attributes
    DigitalOut runLed;
    DigitalOut clipLed;
    AnalogOut dac;

    //extern float frequency(float lowerThreshold, float upperThreshold, int correction);
    bool waveState = 0;
    //float lastVout;
};

UpdateOutputs类中的函数示例

float UpdateOutput::squareWave(int tmr, float period){
    float Vout = 0.0f;
    //float period5 = period/1.587401052;
    float resultingWave;

    float x = (float)(tmr % (int)period)/period;

    if (x > 0.5f){
        resultingWave = 1.0f;
    }
    else{
        Vout = 0.0f;
    }

    Vout = (resultingWave/WAVE_DEVIDOR)+(0.25f); //translate wave to work between 0 and 1 rather than -1 and 1
    if (Vout > 1){
        clipLed = 1;
        Vout = 1.0f;
    }
    else if (Vout < 0.0f){
        clipLed = 1;
        Vout = 0.0f;
    }
    //printf("Vout = %5.3f\n\r", Vout);
    return Vout;
}//end of squareWave
c++ embedded mbed nucleo
1个回答
1
投票

你正在使用 AnalogOut Vout(A0); 作为你的DAC输出,在 main(). 也许你打算更新 UpdateOutput::dac 直接在班级&gt。

A0 是分配给 PA_3PinNames.h周边引脚图(PeripheralPinMaps.h 有。

//*** DAC ***

MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_DAC[] = {
    {PA_4,       DAC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC_OUT1
    {PA_5,       DAC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC_OUT2
    {NC, NC, 0}
};

所以它是 AnalogOut Vout(A0); 是无效的。D13 分配给 UpdateOutput::dac 的别称,是 PA_5 然而是正确的。

你可以改变 AnalogOut Vout(A0)AnalogOut Vout(D13);但我怀疑,你要么是,要么是打算更新 UpdateOutput::dac 在波形发生器函数本身,而不是分配它们的返回值。

© www.soinside.com 2019 - 2024. All rights reserved.