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.

[参考译文] MSPM0G3507-Q1:MSPM0G3507-Q1可以提供示例帮助

Guru**** 2468460 points
Other Parts Discussed in Thread: MSPM0G3507, TCAN1042DEVM

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

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1303996/mspm0g3507-q1-mspm0g3507-q1-can-example-help

器件型号:MSPM0G3507-Q1
主题中讨论的其他器件:MSPM0G3507TCAN1042DEVM

您好、TI 团队:

我遇到了在 CRO 上进行 CAN 传输信号检测的问题。

我正在使用  MSPM0G3507 Launchpad 中"mspm0_SDK_1_20_01_06"的"mcan_multi_message_tx"示例代码。 在此代码中、我注释了微控制器等待开关按压的部分。  

我 没有  适用于 CAN 的 TCAN1042DEVM 板。 我只是检查 CRO 上 PA12引脚上的 CAN 发送信号。 但是、 将探头连接到 CAN TX 引脚 PA12时、CRO 上不会显示数据/波形。

是否可以在不使用   TCAN1042DEVM 板的情况下获得 CRO 上的数据/波形?  请帮助我解决此问题。

以下是我使用的代码  

/*
* Copyright (c) 2021, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "ti_msp_dl_config.h"

#define LED0_STATUS_ON ((uint8_t) 0x01)
#define LED0_STATUS_OFF ((uint8_t) 0x00)
#define LED1_STATUS_ON ((uint8_t) 0x01)
#define LED1_STATUS_OFF ((uint8_t) 0x00)

volatile bool gTXMsg;
volatile bool error;

int main(void)
{
DL_MCAN_TxBufElement txMsg0;
DL_MCAN_TxBufElement txMsg1;

SYSCFG_DL_init();

/* Initialize message0 to transmit. */

/* Identifier Value. */
txMsg0.id = ((uint32_t)(0x4)) << 18U;
/* Transmit data frame. */
txMsg0.rtr = 0U;
/* 11-bit standard identifier. */
txMsg0.xtd = 0U;
/* ESI bit in CAN FD format depends only on error passive flag. */
txMsg0.esi = 0U;
/* Transmitting 4 bytes. */
txMsg0.dlc = 1U;
/* CAN FD frames transmitted with bit rate switching. */
txMsg0.brs = 1U;
/* Frame transmitted in CAN FD format. */
txMsg0.fdf = 1U;
/* Store Tx events. */
txMsg0.efc = 1U;
/* Message Marker. */
txMsg0.mm = 0xAAU;
/* Data bytes. */
txMsg0.data[0] = LED0_STATUS_ON;

/* Initialize message1 to transmit. */

/* Identifier Value. */
txMsg1.id = ((uint32_t)(0x3)) << 18U;
/* Transmit data frame. */
txMsg1.rtr = 0U;
/* 11-bit standard identifier. */
txMsg1.xtd = 0U;
/* ESI bit in CAN FD format depends only on error passive flag. */
txMsg1.esi = 0U;
/* Transmitting 4 bytes. */
txMsg1.dlc = 1U;
/* CAN FD frames transmitted with bit rate switching. */
txMsg1.brs = 1U;
/* Frame transmitted in CAN FD format. */
txMsg1.fdf = 1U;
/* Store Tx events. */
txMsg1.efc = 1U;
/* Message Marker. */
txMsg1.mm = 0xAAU;
/* Data bytes. */
txMsg1.data[0] = LED1_STATUS_ON;

//NVIC_EnableIRQ(GPIO_SWITCHES_INT_IRQN);

while (DL_MCAN_OPERATION_MODE_NORMAL != DL_MCAN_getOpMode(MCAN0_INST))
;

while (1) {
/* Waits until button is pressed to send the message*/
/*
while (gTXMsg == false) {
__WFE();
}
gTXMsg = false;

if (txMsg0.data[0] == LED0_STATUS_ON) {
txMsg0.data[0] = LED0_STATUS_OFF;
} else {
txMsg0.data[0] = LED0_STATUS_ON;
}

if (txMsg1.data[0] == LED1_STATUS_ON) {
txMsg1.data[0] = LED1_STATUS_OFF;
} else {
txMsg1.data[0] = LED1_STATUS_ON;
}
*/
/* Write Tx Message to the Message RAM. */
DL_MCAN_writeMsgRam(MCAN0_INST, DL_MCAN_MEM_TYPE_BUF, 0, &txMsg0);

/* Write Tx Message to the Message RAM. */
DL_MCAN_writeMsgRam(MCAN0_INST, DL_MCAN_MEM_TYPE_BUF, 1, &txMsg1);

/* Add request for transmission. */
DL_MCAN_TXBufAddReq(MCAN0_INST, 0);

/* Add request for transmission. */
DL_MCAN_TXBufAddReq(MCAN0_INST, 1);
}
}

void GROUP1_IRQHandler(void)
{
switch (DL_Interrupt_getPendingGroup(DL_INTERRUPT_GROUP_1)) {
case GPIO_SWITCHES_INT_IIDX:
switch (DL_GPIO_getPendingInterrupt(GPIO_SWITCHES_PORT)) {
case DL_GPIO_IIDX_DIO21:
gTXMsg = true;
break;
default:
break;
}
break;
default:
break;
}
}

感谢您发送  

迪帕克

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

    您好!

    在论坛上发帖时、请使用您的帖子进行更详细的描述。 此外、在向论坛发布代码时、请使用插入 "Code"菜单选项来对其进行格式化、以确保可读性。 我已经编辑了您的帖子以反映这些更改。  

    我建议您按原样使用代码示例、而无需首先进行修改来测试您的硬件设置、以确保一切正常运行、从而让您了解代码流程。 通过以现有方式修改示例、现在可以不断覆盖 CAN 消息 RAM、而不用等待任何传输、因此无法开始或完成传输。  

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

    您好 Jace H:

    我正在使用具有切换 LED 的500ms 延迟。 每500ms LED 切换一次、但 CRO 上不会出现任何 TX 数据...

    我 还在共享代码...

    /*
     * Copyright (c) 2021, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    #include "ti_msp_dl_config.h"
    
    /* This results in approximately 0.5s of delay assuming 32MHz CPU_CLK */
    #define DELAY (16000000)
    
    #define LED0_STATUS_ON ((uint8_t) 0x01)
    #define LED0_STATUS_OFF ((uint8_t) 0x00)
    #define LED1_STATUS_ON ((uint8_t) 0x01)
    #define LED1_STATUS_OFF ((uint8_t) 0x00)
    
    volatile bool gTXMsg;
    volatile bool error;
    
    int main(void)
    {
        DL_MCAN_TxBufElement txMsg0;
        DL_MCAN_TxBufElement txMsg1;
    
        SYSCFG_DL_init();
    
        /* Initialize message0 to transmit. */
    
        /* Identifier Value. */
        txMsg0.id = ((uint32_t)(0x4)) << 18U;
        /* Transmit data frame. */
        txMsg0.rtr = 0U;
        /* 11-bit standard identifier. */
        txMsg0.xtd = 0U;
        /* ESI bit in CAN FD format depends only on error passive flag. */
        txMsg0.esi = 0U;
        /* Transmitting 4 bytes. */
        txMsg0.dlc = 1U;
        /* CAN FD frames transmitted with bit rate switching. */
        txMsg0.brs = 1U;
        /* Frame transmitted in CAN FD format. */
        txMsg0.fdf = 1U;
        /* Store Tx events. */
        txMsg0.efc = 1U;
        /* Message Marker. */
        txMsg0.mm = 0xAAU;
        /* Data bytes. */
        txMsg0.data[0] = LED0_STATUS_ON;
    
        /* Initialize message1 to transmit. */
    
        /* Identifier Value. */
        txMsg1.id = ((uint32_t)(0x3)) << 18U;
        /* Transmit data frame. */
        txMsg1.rtr = 0U;
        /* 11-bit standard identifier. */
        txMsg1.xtd = 0U;
        /* ESI bit in CAN FD format depends only on error passive flag. */
        txMsg1.esi = 0U;
        /* Transmitting 4 bytes. */
        txMsg1.dlc = 1U;
        /* CAN FD frames transmitted with bit rate switching. */
        txMsg1.brs = 1U;
        /* Frame transmitted in CAN FD format. */
        txMsg1.fdf = 1U;
        /* Store Tx events. */
        txMsg1.efc = 1U;
        /* Message Marker. */
        txMsg1.mm = 0xAAU;
        /* Data bytes. */
        txMsg1.data[0] = LED1_STATUS_ON;
    
        //NVIC_EnableIRQ(GPIO_SWITCHES_INT_IRQN);
    
        while (DL_MCAN_OPERATION_MODE_NORMAL != DL_MCAN_getOpMode(MCAN0_INST))
            ;
    
        //DL_GPIO_setPins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_1_PIN);
        while (1) {
            /* Waits until button is pressed to send the message*/
    
    
          //  while (gTXMsg == false) {
           //     __WFE();
           // }
            delay_cycles(DELAY);
            gTXMsg = false;
    
            if (txMsg0.data[0] == LED0_STATUS_ON) {
                txMsg0.data[0] = LED0_STATUS_OFF;
            } else {
                txMsg0.data[0] = LED0_STATUS_ON;
            }
    
            if (txMsg1.data[0] == LED1_STATUS_ON) {
                txMsg1.data[0] = LED1_STATUS_OFF;
            } else {
                txMsg1.data[0] = LED1_STATUS_ON;
            }
    
            /* Write Tx Message to the Message RAM. */
            DL_MCAN_writeMsgRam(MCAN0_INST, DL_MCAN_MEM_TYPE_BUF, 0, &txMsg0);
    
            /* Write Tx Message to the Message RAM. */
            DL_MCAN_writeMsgRam(MCAN0_INST, DL_MCAN_MEM_TYPE_BUF, 1, &txMsg1);
    
            /* Add request for transmission. */
            DL_MCAN_TXBufAddReq(MCAN0_INST, 0);
    
            /* Add request for transmission. */
            DL_MCAN_TXBufAddReq(MCAN0_INST, 1);
    
            delay_cycles(DELAY);
            DL_GPIO_togglePins(GPIO_LEDS_PORT,GPIO_LEDS_USER_LED_1_PIN);
        }
    
    }
    
    void GROUP1_IRQHandler(void)
    {
        switch (DL_Interrupt_getPendingGroup(DL_INTERRUPT_GROUP_1)) {
            case GPIO_SWITCHES_INT_IIDX:
                switch (DL_GPIO_getPendingInterrupt(GPIO_SWITCHES_PORT)) {
                    case DL_GPIO_IIDX_DIO21:
                        gTXMsg = true;
                        break;
                    default:
                        break;
                }
                break;
            default:
                break;
        }
    }
    
    

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

    Deepak,

    查看原始未修改示例的代码流程。 如果您要使用计时器作为触发器、而不是 GPIO 输入、那么如果代码流程相同、则需要在计时器 ISR 中执行与 GPIO ISR 相同的操作。  

    另外、回头看看您的初始请求、如果您只是尝试验证您的代码正在传输某些内容、没有附加 TCAN、那么就使用环回模式进行测试。  

    话虽如此、在修改之前、请返回到初始示例而未修改、并验证设置是否有效。