Other Parts Discussed in Thread: HALCOGEN
Hello,
I'm trying to send some data with DMA and DCAN1 on Hercules,TMS570LC43X launchapd ,but have a problem.
I try to send some data with DMA and DCAN1,but couldn't send data with DMA.
/** @file HL_sys_main.c
* @brief Application main file
* @date 05-Oct-2016
* @version 04.06.00
*
* This file contains an empty main function,
* which can be used for the application.
*/
/*
* Copyright (C) 2009-2016 Texas Instruments Incorporated - www.ti.com
*
*
* 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.
*
*/
/* USER CODE BEGIN (0) */
/* USER CODE END */
/* Include Files */
#include "HL_sys_common.h"
/* USER CODE BEGIN (1) */
#include "HL_sys_dma.h"
#include "HL_sci.h"
#include "HL_can.h"
#include "stdio.h"
/* USER CODE END */
/** @fn void main(void)
* @brief Application main function
* @note This function is empty by default.
*
* This function is called after startup.
* The user can use this function to implement the application.
*/
/* USER CODE BEGIN (2) */
#define size 8
/* Tx and Rx data buffer */
uint8_t TX_DATA[size], RX_DATA[size] = {0};
/* Addresses of CAN1 IF1 and IF2 8-bit TX/Rx data */
#if ((__little_endian__ == 1) || (__LITTLE_ENDIAN__ == 1))
#define CAN1_TX_ADDR ((uint32_t)(&(canREG1->IF1DATx[0])))
#define CAN1_RX_ADDR ((uint32_t)(&(canREG1->IF2DATx[0])))
#else
#define CAN1_TX_ADDR ((uint32_t)(&(canREG1->IF1DATx[0])) + 3)
#define CAN1_RX_ADDR ((uint32_t)(&(canREG1->IF2DATx[0])) + 3)
#endif
#define DMA_CAN1_TX DMA_REQ8
#define DMA_CAN1_RX DMA_REQ6
/* USER CODE END */
int main(void)
{
/* USER CODE BEGIN (3) */
uint32 CAN1TxData;
int i;
g_dmaCTRL g_dmaCTRLPKT1;
/*Load source data*/
for (i=0; i<size; i++)
{
TX_DATA[i] = i;
}
/*Initialize CAN*/
canInit();
/* Enable CAN loopback */
canEnableloopback(canREG1,Internal_Lbk);
//Enable DE1 bit in CTL register to trigger DMA when IF1 data
canREG1->CTL |= (1U << 18U);
/*Assign DMA request DCAN1 IF1 transmit to Channel 0*/
dmaReqAssign(DMA_CH0, DMA_CAN1_TX);
CAN1TxData = CAN1_TX_ADDR;
/*Configure control packet for Channel 0*/
g_dmaCTRLPKT1.SADD = (uint32_t)TX_DATA; /* source address */
g_dmaCTRLPKT1.DADD = CAN1TxData; /* destination address */
g_dmaCTRLPKT1.CHCTRL = 0; /* channel control */
g_dmaCTRLPKT1.FRCNT = size; /* frame count */
g_dmaCTRLPKT1.ELCNT = 1; /* element count */
g_dmaCTRLPKT1.ELDOFFSET = 0; /* element destination offset */
g_dmaCTRLPKT1.ELSOFFSET = 0; /* element destination offset */
g_dmaCTRLPKT1.FRDOFFSET = 0; /* frame destination offset */
g_dmaCTRLPKT1.FRSOFFSET = 0; /* frame destination offset */
g_dmaCTRLPKT1.PORTASGN = PORTA_READ_PORTB_WRITE;
g_dmaCTRLPKT1.RDSIZE = ACCESS_8_BIT; /* read size */
g_dmaCTRLPKT1.WRSIZE = ACCESS_8_BIT; /* write size */
g_dmaCTRLPKT1.TTYPE = FRAME_TRANSFER; /* transfer type */
g_dmaCTRLPKT1.ADDMODERD = ADDR_INC1; /* address mode read */
g_dmaCTRLPKT1.ADDMODEWR = ADDR_FIXED; /* address mode write */
g_dmaCTRLPKT1.AUTOINIT = AUTOINIT_OFF; /* autoinit */
/*Set control packet for channel 0 */
dmaSetCtrlPacket(DMA_CH0, g_dmaCTRLPKT1);
/*Set dma channel 0 to trigger on hardware request*/
dmaSetChEnable(DMA_CH0, DMA_HW);
/*Enable DMA*/
dmaEnable();
/*transmit message*/
canREG1->IF1CMD = 0x87U;
canREG1->IF1NO =1;
while(1);
/* USER CODE END */
}
/* USER CODE BEGIN (4) */
/* USER CODE END */
please check my code!
I would appreiate if someone could reply to my question.


