TI中文支持网
TI专业的中文技术问题搜集分享网站

TMS570LC4357的SCI1串口DMA接收问题

用非DMA方式中断接收数据能进SCI1接收中断,配置为DMA方式后就不行了,下面是我的SCI1和DMA配置代码

void Init_SCI1(void)
{
    sciREG1->GCR0 = 0U;
    sciREG1->GCR0 = 1U;

    /** – Disable all interrupts */
    sciREG1->CLEARINT    = 0xFFFFFFFFU;
    sciREG1->CLEARINTLVL = 0xFFFFFFFFU;

    /** – global control 1 */
    sciREG1->GCR1 =  (uint32)((uint32)1U << 25U)  /* enable transmit */
                  | (uint32)((uint32)1U << 24U)  /* enable receive */
                  | (uint32)((uint32)0U << 10U)  //多缓冲模式
                  | (uint32)((uint32)1U << 5U)   /* internal clock (device has no clock pin) */
                  | (uint32)((uint32)(2U-1U) << 4U)  /* number of stop bits */
                  | (uint32)((uint32)0U << 3U)  /* even parity, otherwise odd */
                  | (uint32)((uint32)0U << 2U)  /* enable parity */
                  | (uint32)((uint32)0U << 1U);  /* 同步模式*/

    /** – set baudrate */
    sciREG1->BRS = 74;//487U;  /* baudrate */

    /** – transmission length */
    sciREG1->FORMAT = 7;  /* length */

    /** – set SCI1 pins functional mode */
    sciREG1->PIO0 = (uint32)((uint32)1U << 2U)  /* tx pin */
                 | (uint32)((uint32)1U << 1U); /* rx pin */

    /** – set SCI1 pins default output value */
    sciREG1->PIO3 = (uint32)((uint32)0U << 2U)  /* tx pin */
                 | (uint32)((uint32)0U << 1U); /* rx pin */

    /** – set SCI1 pins output direction */
    sciREG1->PIO1 = (uint32)((uint32)0U << 2U)  /* tx pin */
                 | (uint32)((uint32)0U << 1U); /* rx pin */

    /** – set SCI1 pins open drain enable */
    sciREG1->PIO6 = (uint32)((uint32)0U << 2U)  /* tx pin */
                 | (uint32)((uint32)0U << 1U); /* rx pin */

    /** – set SCI1 pins pullup/pulldown enable */
    sciREG1->PIO7 = (uint32)((uint32)0U << 2U)  /* tx pin */
                 | (uint32)((uint32)0U << 1U); /* rx pin */

    /** – set SCI1 pins pullup/pulldown select */
    sciREG1->PIO8 = (uint32)((uint32)1U << 2U)  /* tx pin */
                 | (uint32)((uint32)1U << 1U);  /* rx pin */

    /** – set interrupt level */
    sciREG1->SETINTLVL = (uint32)((uint32)0U << 26U)  /* Framing error */
                      | (uint32)((uint32)0U << 25U)  /* Overrun error */
                      | (uint32)((uint32)0U << 24U)  /* Parity error */
                      | (uint32)((uint32)1U << 9U)  /* Receive */
                      | (uint32)((uint32)0U << 8U)  /* Transmit */
                      | (uint32)((uint32)0U << 1U)  /* Wakeup */
                      | (uint32)((uint32)0U << 0U);  /* Break detect */

    /** – set interrupt enable */
    sciREG1->SETINT = (uint32)((uint32)0U << 26U)  /* Framing error */
                   | (uint32)((uint32)0U << 25U)  /* Overrun error */
                   | (uint32)((uint32)0U << 24U)  /* Parity error */
                   | (uint32)((uint32)1U << 18U)//SET RX DMA ALL
                   | (uint32)((uint32)1U << 17U)//SET RX DMA
                   | (uint32)((uint32)1U << 9U)  /* Receive */
                   | (uint32)((uint32)0U << 1U)  /* Wakeup */
                   | (uint32)((uint32)0U << 0U);  /* Break detect */

    /** – initialize global transfer variables */
    g_sciTransfer_t[0U].mode   = (uint32)0U << 8U;
    g_sciTransfer_t[0U].tx_length = 0U;
    g_sciTransfer_t[0U].rx_length = 0U;

    /** – Finaly start SCI1 */
    sciREG1->GCR1 |= 0x80U;
}

void Init_DMA_Channl0(unsigned char *source_address)
{
    struct dmaCTRLPKT DMA_CTRL;
    //dmaEnableECC();//使能ECC校验
    DMA_CTRL.SADD      = (uint32)(&(sciREG1->RD)) + dest_addr_offfset;//初始化源地址
    DMA_CTRL.DADD      = (uint32)(source_address);//初始化目标地址
    DMA_CTRL.FRCNT     = 0;
    DMA_CTRL.ELCNT     = 10;//每10个字节为一个数据包
    DMA_CTRL.CHCTRL    = 0;//选择通道0
    DMA_CTRL.RDSIZE    = ACCESS_8_BIT;//接收一个字节为一个最小单位
    DMA_CTRL.WRSIZE    = ACCESS_8_BIT;//发送一个字节为一个最小单位
    DMA_CTRL.TTYPE     = FRAME_TRANSFER;//一个请求触发一个帧传送
    DMA_CTRL.ADDMODERD = ADDR_FIXED;//源地址模式为固定
    DMA_CTRL.ADDMODEWR = ADDR_INC1;//目标地址为增量方式
    DMA_CTRL.AUTOINIT  = AUTOINIT_OFF;
    DMA_CTRL.PORTASGN  = PORTB_READ_PORTA_WRITE;//端口分配外设读,内存写
    dmaSetCtrlPacket(DMA_CH0, DMA_CTRL);
    dmaEnableInterrupt(DMA_CH0,FTC,DMA_INTB);
    dmaReqAssign(DMA_CH0,DMA_REQ28);//SCI1接收位于Line28
    dmaSetPriority(DMA_CH0,HIGHPRIORITY);
    vimChannelMap(33,33, &DMA_Channl0_ISR);
    vimEnableInterrupt(33, SYS_FIQ);//快速中断模式
}

vimREG->FIRQPR1 = (uint32)((uint32)SYS_IRQ << 0U)//channel_32
                    | (uint32)((uint32)SYS_FIQ << 1U)//DMA0配置为快速中断模式
                    | (uint32)((uint32)SYS_IRQ << 2U)//channel_34
                    | (uint32)((uint32)SYS_IRQ << 3U)//channel_35
                    | (uint32)((uint32)SYS_IRQ << 4U)//channel_36

vimREG->REQMASKSET1 = (uint32)((uint32)0U << 0U)
                        | (uint32)((uint32)1U << 1U)//使能DMA中断
                        | (uint32)((uint32)0U << 2U)
                        | (uint32)((uint32)0U << 3U)
                        | (uint32)((uint32)0U << 4U)

另外,DMA配置的是硬件请求模式,中断向量表也是初始化了的,大家帮我看看会是哪里问题,谢谢

Susan Yang:

关于这个我们是有专门的技术文档的。您可以参考一下下面的链接(包含了相关的示例程序)

www.ti.com/…/spna213.pdf

user18914063:

回复 Susan Yang:

你好,这个文档我看了,代码我前几天也下载看了,编译成功后下载的时候报错,提示说是不能和目标的端序匹配,看了下,也不知道怎么修改才对,另外,我贴出来的这个自己的代码也尝试对照着这个官方的参考代码进行修改,也是不行

Susan Yang:

回复 user18914063:

您可以尝试在Halcogen中TMS570LC4357 > R5-MPU-PMU > Cortex-R5 > 取消选中 Enable Cache

或者将缓存配置为write through 模式,以确保RAM和缓存中的数据匹配

user18914063:

回复 Susan Yang:

哦,按照你提示的方法,我才发现这个官方的例程是针对TMS570LS1227的,这个MCU和LC4357应该是不兼容的吧,LC4357是Cortex-R5

Susan Yang:

回复 user18914063:

是的,所以要进行上面的修改

user18914063:

回复 user18914063:

进调试模式的时候,我也看了DMA通道挂起寄存器,发现当我在PC端的出口助手里面发数据的时候,DMA的Line28发生了中断挂起事件的,只是系统中断没有对这个事件响应,但是我的代码里面对系统VIM都做了配置的啊,好奇怪

赞(0)
未经允许不得转载:TI中文支持网 » TMS570LC4357的SCI1串口DMA接收问题
分享到: 更多 (0)