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.

[参考译文] AM2434:UART 多点奇偶校验地址匹配模式不起作用

Guru**** 2414260 points
Other Parts Discussed in Thread: AM2434

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

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1351374/am2434-uart-multi-drop-parity-address-match-mode-is-not-working

器件型号:AM2434

您好!

我当前正在尝试在 AM243x 的 M4F 内核上运行 UART 多点奇偶校验地址匹配模式。


我已经为此编写了以下代码:

// Included Files
#include "serial_communication.h"   // Contains all necessary headers

#define SERIAL_TASK_PRI   (3u)
#define SERIAL_TASK_SIZE (1024u)

#define APP_UART_BUFSIZE              (200U)
#define APP_UART_RECEIVE_BUFSIZE      (8U)

StackType_t serialTaskStack[SERIAL_TASK_SIZE] __attribute__((aligned(32)));
StaticTask_t gSerialTaskObj;
TaskHandle_t serialTask;

uint8_t gUartBuffer[APP_UART_BUFSIZE] = {0x01, 0x02, 0x03};
uint8_t gUartReceiveBuffer[APP_UART_RECEIVE_BUFSIZE];

UART_Transaction trans;

void serial_main(void *args)
{
    TickType_t xLastWakeTime;
    xLastWakeTime = xTaskGetTickCount();

    for(;;)
    {
        int32_t transferOK;
        UART_Transaction_init(&trans);

        /* Send data */
//        HW_WR_REG32(((uint32_t)gUartHandle[COMM_UART1] + UART_ECR), (HW_RD_REG32((uint32_t)gUartHandle[COMM_UART1] + UART_ECR) | 0x01));  // Next byte is written as an address byte
        trans.buf   = &gUartBuffer[0U];
        trans.count = 3;
        transferOK = UART_write(gUartHandle[COMM_UART1], &trans);
        DebugP_log("Message sent!\r\n");

//TODO: xTaskDelayUntil()
        vTaskDelay(1000 / portTICK_PERIOD_MS);     // Set the overall task period to 1ms
    }
}



void empty_main(void *args)
{
    /* Open drivers to open the UART driver for console */
    Drivers_open();
    Board_driversOpen();

//    // Enable Multi-drop Parity Address Match Mode
//    HW_WR_REG32(((uint32_t)gUartHandle[COMM_UART1] + UART_ECR), (HW_RD_REG32((uint32_t)gUartHandle[COMM_UART1] + UART_ECR) & 0xFFFFFFF7));      // Disable Receive Mode
//    HW_WR_REG32(((uint32_t)gUartHandle[COMM_UART1] + UART_EFR2), (HW_RD_REG32((uint32_t)gUartHandle[COMM_UART1] + UART_EFR2) | 0x00000004));    // Enable Multi-drop address match mode
//    HW_WR_REG32(((uint32_t)gUartHandle[COMM_UART1] + UART_MAR), (uint32_t)0x10);                                                                // Set matching device address
//    HW_WR_REG32(((uint32_t)gUartHandle[COMM_UART1] + UART_MMR), (uint32_t)0xFF);                                                                // Set address match masking
//    HW_WR_REG32(((uint32_t)gUartHandle[COMM_UART1] + UART_MBR), (uint32_t)0xFF);                                                                // Set broadcast address match
//    HW_WR_REG32(((uint32_t)gUartHandle[COMM_UART1] + UART_EFR2), (HW_RD_REG32((uint32_t)gUartHandle[COMM_UART1] + UART_EFR2) | 0x00000080));    // Enable broadcast address matching (if needed)
//    HW_WR_REG32(((uint32_t)gUartHandle[COMM_UART1] + UART_ECR), (HW_RD_REG32((uint32_t)gUartHandle[COMM_UART1] + UART_ECR) | 0x08));            // Enable RX

    /* create the tasks, order of task creation does not matter for this example */
    serialTask = xTaskCreateStatic( serial_main,        /* Pointer to the function that implements the task. */
                                  "Serial_polling",     /* Text name for the task.  This is to facilitate debugging only. */
                                  SERIAL_TASK_SIZE,     /* Stack depth in units of StackType_t typically uint32_t on 32b CPUs */
                                  NULL,                 /* We are not using the task parameter. */
                                  SERIAL_TASK_PRI,      /* task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest */
                                  serialTaskStack,      /* pointer to stack base */
                                  &gSerialTaskObj );    /* pointer to statically allocated task object memory */
    configASSERT(serialTask != NULL);
    DebugP_log("The task is created!\r\n");

    Board_driversClose();

    /* Don't close drivers to keep the UART driver open for console */
    /* Drivers_close(); */
}

(在 main.c 中只会创建一个一次性任务,该任务会调用 empty_maine()函数,并启动调度程序)


使用注释的多点使能例程、程序通过 UART 接口工作并发送相应的字节。 但是、当我激活多点模式(取消代码注释)时、微控制器会卡在那里、不处理任何其他内容。 这样做的原因是什么? 而且 M4F 内核完全支持多点匹配模式吗?

感谢您的帮助!

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

    快速更新:

    必须在 uart_open()之前设置寄存器,这样寄存器值现在可以正确写入。 但我只能 发送没有地址奇偶校验位的8位消息。 是否有可能 AM2434不支持多点模式、

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

    你好、Joshua、

    感谢您访问 TI E2E 支持论坛。

    我很乐意在这个问题上为您提供帮助。

    我想事先知道几件事:

    您是最新的 MCU + SDK 版本吗?

    2.您可以发送整个项目文件给我浏览并在我的设置中运行它而不是简单的 main.c 文件吗?

    3.此应用是在 AM243-LP 还是 AM243-EVM 上运行?

    4.同时查看您的代码、它是一个 FreeRTOS 应用程序、对吗?

    期待您的答复。

    此致、

    瓦伊布哈夫

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

    尊敬的 Vaibhav Kumar:

    感谢您的答复!

    更好地回答您的问题:

    1.我目前使用的是最新的 MCU Plus SDK 版本。

    2.我在下面附上我的全部代码

    3.我使用的是 AM243-EVM.

    4.是的、我想使用 FreeRTOS 应用程序。

    main.h:

    #ifndef MAIN_H_
    #define MAIN_H_
    
    // Included Files
    #include <stdlib.h>
    #include <string.h>
    #include <kernel/dpl/DebugP.h>
    #include "ti_drivers_config.h"
    #include "ti_board_config.h"
    #include "ti_drivers_open_close.h"
    #include "ti_board_open_close.h"
    #include "FreeRTOS.h"
    #include "task.h"
    #include <drivers/hw_include/hw_types.h>
    
    #endif /* MAIN_H_ */

    main.c:

    // Included files
    #include "main.h"
    
    #define MAIN_TASK_PRI  (configMAX_PRIORITIES-1)
    #define MAIN_TASK_SIZE (16384U/sizeof(configSTACK_DEPTH_TYPE))
    
    StackType_t gMainTaskStack[MAIN_TASK_SIZE] __attribute__((aligned(32)));
    
    StaticTask_t gMainTaskObj;
    TaskHandle_t gMainTask;
    
    void empty_main(void *args);
    
    void freertos_main(void *args)
    {
        empty_main(NULL);
    
        vTaskDelete(NULL);
    }
    
    int main()
    {
        /* init SOC specific modules */
        System_init();
        Board_init();
    
        /* This task is created at highest priority, it should create more tasks and then delete itself */
        gMainTask = xTaskCreateStatic( freertos_main,   /* Pointer to the function that implements the task. */
                                      "freertos_main", /* Text name for the task.  This is to facilitate debugging only. */
                                      MAIN_TASK_SIZE,  /* Stack depth in units of StackType_t typically uint32_t on 32b CPUs */
                                      NULL,            /* We are not using the task parameter. */
                                      MAIN_TASK_PRI,   /* task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest */
                                      gMainTaskStack,  /* pointer to stack base */
                                      &gMainTaskObj ); /* pointer to statically allocated task object memory */
        configASSERT(gMainTask != NULL);
    
    //    empty_main(NULL);
    
        /* Start the scheduler to start the tasks executing. */
        vTaskStartScheduler();
    
        /* vTaskStartScheduler() only returns if there was not enough FreeRTOS heap memory available */
        DebugP_log("Heap memory overflow! Should never be reached!\r\n");
        DebugP_assertNoLog(0);
    
        return 0;
    }

    serial_communication.h:

    #ifndef SERIAL_COMMUNICATION_H_
    #define SERIAL_COMMUNICATION_H_
    
    // Included Files
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <kernel/dpl/DebugP.h>
    #include <kernel/dpl/ClockP.h>
    #include <kernel/dpl/HwiP.h>
    #include <inttypes.h>
    #include "ti_drivers_config.h"
    #include "ti_board_config.h"
    #include "ti_drivers_open_close.h"
    #include "ti_board_open_close.h"
    #include "FreeRTOS.h"
    #include "task.h"
    #include <drivers/hw_include/hw_types.h>
    #include <semphr.h>
    
    void toggleLED(uint32_t addr, uint32_t pinNum);
    
    #endif /* SERIAL_COMMUNICATION_H_ */

    serial_communication.c:

    // Included Files
    #include "serial_communication.h"
    
    #define SERIAL_TASK_PRI   (3u)
    #define SERIAL_TASK_SIZE (1024u)
    
    #define APP_UART_BUFSIZE              (200U)
    #define APP_UART_RECEIVE_BUFSIZE      (8U)
    
    StackType_t serialTaskStack[SERIAL_TASK_SIZE] __attribute__((aligned(32)));
    StaticTask_t gSerialTaskObj;
    TaskHandle_t serialTask;
    
    uint8_t gUartBuffer[APP_UART_BUFSIZE] = {0x01, 0x02, 0x03};
    uint8_t gUartReceiveBuffer[APP_UART_RECEIVE_BUFSIZE];
    
    UART_Transaction trans;
    
    void serial_main(void *args)
    {
        TickType_t xLastWakeTime;
        xLastWakeTime = xTaskGetTickCount();
    
        for(;;)
        {
            int32_t transferOK;
            UART_Transaction_init(&trans);
    
            /* Send data */
            HW_WR_REG32(((uint32_t)gUartHandle[COMM_UART1] + UART_ECR), (HW_RD_REG32((uint32_t)gUartHandle[COMM_UART1] + UART_ECR) | 0x01));        // Next byte is an address byte
            trans.buf   = &gUartBuffer[0U];
            trans.count = 1;
            transferOK = UART_write(gUartHandle[COMM_UART1], &trans);
            HW_WR_REG32(((uint32_t)gUartHandle[COMM_UART1] + UART_ECR), (HW_RD_REG32((uint32_t)gUartHandle[COMM_UART1] + UART_ECR) & 0xFFFFFFFE));  // Next byte is an address byte
    
            trans.buf   = &gUartBuffer[1U];
            trans.count = 2;
            transferOK = UART_write(gUartHandle[COMM_UART1], &trans);
            DebugP_log("Message sent!\r\n");
    
    //TODO: xTaskDelayUntil()
            vTaskDelay(1000 / portTICK_PERIOD_MS);     // Set the overall task period to 1ms
        }
    }
    
    
    
    void empty_main(void *args)
    {
    
        // Enable Multi-drop Parity Address Match Mode
        HW_WR_REG32(((uint32_t)gUartHandle[COMM_UART1] + UART_ECR), (HW_RD_REG32((uint32_t)gUartHandle[COMM_UART1] + UART_ECR) & 0xFFFFFFF7));      // Disable Receive Mode
        HW_WR_REG32(((uint32_t)gUartHandle[COMM_UART1] + UART_EFR2), (HW_RD_REG32((uint32_t)gUartHandle[COMM_UART1] + UART_EFR2) | 0x00000004));    // Enable Multi-drop address match mode
        HW_WR_REG32(((uint32_t)gUartHandle[COMM_UART1] + UART_MAR), (uint32_t)0x10);                                                                // Set matching device address
        HW_WR_REG32(((uint32_t)gUartHandle[COMM_UART1] + UART_MMR), (uint32_t)0xFF);                                                                // Set address match masking
        HW_WR_REG32(((uint32_t)gUartHandle[COMM_UART1] + UART_MBR), (uint32_t)0xFF);                                                                // Set broadcast address match
        HW_WR_REG32(((uint32_t)gUartHandle[COMM_UART1] + UART_EFR2), (HW_RD_REG32((uint32_t)gUartHandle[COMM_UART1] + UART_EFR2) | 0x00000080));    // Enable broadcast address matching (if needed)
        HW_WR_REG32(((uint32_t)gUartHandle[COMM_UART1] + UART_ECR), (HW_RD_REG32((uint32_t)gUartHandle[COMM_UART1] + UART_ECR) | 0x08));            // Enable RX
    
        /* Open drivers to open the UART driver for console */
        Drivers_open();
        Board_driversOpen();
    
        /* then create the tasks, order of task creation does not matter for this example */
        serialTask = xTaskCreateStatic( serial_main,        /* Pointer to the function that implements the task. */
                                      "Serial_polling",     /* Text name for the task.  This is to facilitate debugging only. */
                                      SERIAL_TASK_SIZE,     /* Stack depth in units of StackType_t typically uint32_t on 32b CPUs */
                                      NULL,                 /* We are not using the task parameter. */
                                      SERIAL_TASK_PRI,      /* task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest */
                                      serialTaskStack,      /* pointer to stack base */
                                      &gSerialTaskObj );    /* pointer to statically allocated task object memory */
        configASSERT(serialTask != NULL);
        DebugP_log("The task is created!\r\n");
    
        Board_driversClose();
    
        /* Don't close drivers to keep the UART driver open for console */
        /* Drivers_close(); */
    }

    为了便于您参考、我以  empty_am243x-evm_m4fss0-0_freertos_ti-arm-clang 添加了示例。

    此致、

    约书亚

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

    你好、Joshua、

    感谢您对我的问题的详细答复。

    请允许我花一些时间进行相同的演示。

    此致、

    瓦伊布哈夫

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

    你好、Joshua、

    对于响应延迟、我们深表歉意。

    当我浏览 TRM 时、我知道 TI 的 SDK 产品目前不支持多点技术。

    注: 除了 UART、如果接收器支持 I2C 和 SPI、您可以选择它、因为我看到您的要求是将数据从一个点发送到多个接收器。

    此致、

    瓦伊布哈夫

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

    尊敬的 Vaibhav Kumar:
    感谢您的答复。 我也看到了这一点、只是不确定、因为 TRM 中详细介绍了多分支函数。 但我现在已经通过 另一种方式解决了它。 无论如何、谢谢。

    此致、

    约书亚