c++ - 错误消息:未找到外围设备的引脚图:Nucleo-F429ZI上的0x8009B0B

标签 c++ embedded mbed nucleo

当我将其加载到板上时,会得到未发现外围错误的引脚图。
我对此问题(One of the pages I visited)进行了一些研究,我认为我理解了这个问题,
但是,我使用的所有引脚都完全支持我要它们执行的操作。自从我将代码从过程转换为面向对象(我需要执行此操作以正确实现调度)以来,才出现此问题。

我感觉这与我如何在构造函数成员初始化程序列表中初始化它们有关,因为我不完全了解它的工作原理(我对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

最佳答案

您正在使用AnalogOut Vout(A0);作为main()中的DAC输出。也许您打算直接在class>中更新UpdateOutput::dac
PinNames.h中为A0分配了PA_3,而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);无效的。分配给D13UpdateOutput::dacPA_5的别名,但是正确。

您可以将AnalogOut Vout(A0)更改为AnalogOut Vout(D13);,但是我怀疑您是波形生成器函数本身或打算在波形生成器函数中更新UpdateOutput::dac而不是为其分配返回值。

关于c++ - 错误消息:未找到外围设备的引脚图:Nucleo-F429ZI上的0x8009B0B,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61488228/

相关文章:

c++ - 如何在 C++ 中增加信号量值,解决哲学家用餐问题

c++ - 访问 vector 容器的元素时发生运行时错误

javascript - 设计跨平台多内容类型文件格式的最佳方式?

ssl - 为什么 nodeMCU tls mbed 库从 Pushbullet API 服务器收到错误 40(握手失败)?

c++ - 正确发送消息 UART

c++ - Visual Studio从2005年升级到2015年,C++ GUI保留XP主题而不是系统主题

embedded - u-boot根据GPIO状态选择启动分区

c - 如何使用 IAR 插入内存​​屏障?

security - 如何防止基于UDP的 channel 变成 “backdoor”?