This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] MSP430F5529:MSP430/USB 和 printf 错误

Guru**** 2484615 points
Other Parts Discussed in Thread: MSP430F5529

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1232271/msp430f5529-msp430-usb-and-printf-error

器件型号:MSP430F5529

您好!

我使用 MSP430F5529 Launchpad 与 USB 配合使用以及在 Linux / CCS 12.3.0.00005下运行的 PC。

我使用一个德州仪器的 USB 示例。 这是代码:

void main (void)
{
    WDT_A_hold(WDT_A_BASE);                                                                                         // Stop watchdog timer

    PMM_setVCore(PMM_CORE_LEVEL_2);
    USBHAL_initPorts();                                                                                             // Config GPIOS for low-power (output low)
    USBHAL_initClocks(8000000);                                                                                     // Config clocks. MCLK=SMCLK=FLL=8MHz; ACLK=REFO=32kHz
    USB_setup(TRUE, TRUE);                                                                                          // Init USB & events; if a host is present, connect

    __enable_interrupt();                                                                                           // Enable interrupts globally

    printf("Test\n");

    while (1)
    {
        switch (USB_getConnectionState())                                                                           // Check the USB state and directly main loop accordingly
        {
            case ST_ENUM_ACTIVE:                                                                                    // This case is executed while your device is enumerated on the USB host
                __bis_SR_register(LPM0_bits + GIE);                                                                 // Enter LPM0 (can't do LPM3 when active)
                _NOP();
                if (bHIDDataReceived_event)                                                                         // If true, some data is in the buffer; begin receiving a cmd
                {
                    uint8_t dataReceived[MAX_STR_LENGTH] = "";
                    USBHID_receiveDataInBuffer(dataReceived, MAX_STR_LENGTH, HID0_INTFNUM);
                    bHIDDataReceived_event = FALSE;
                }
                break;

            case ST_PHYS_DISCONNECTED:
            case ST_ENUM_SUSPENDED:
            case ST_PHYS_CONNECTED_NOENUM_SUSP:
                __bis_SR_register(LPM3_bits + GIE);
                _NOP();
                break;

            case ST_ENUM_IN_PROGRESS:
                printf("Here!\n");
                break;

            default:
                _NOP();
                break;
        }

    }
}

如果我删除带有"printf ("here!\n");"的行,则该代码可以与主机完美配合,但如果我想用"printf ("here!\n");"命令在控制台中编写,则 USB 连接失败,我收到以下消息:

MSP430:无法运行目标 CPU:无法运行器件(到断点)
MSP430:停止目标 CPU 时出现问题:内部错误

是否需要进行特定设置来使命令"printf"与 USB 框架兼容?

谢谢你。

克里斯托弗