Ken,
如下是DAM CAN1 IF1发送数据, 请帮我查看寄存器配置是否出现问题?关于IFUEy寄存器 DATASHEET 好像没有说明?
/* USER CODE BEGIN (0) */
#include "rti.h"
#include "can.h"
#include "sys_dma.h"
/* USER CODE END */
/* Include Files */
#include "sys_common.h"
/* USER CODE BEGIN (1) */
#define D_SIZE 8
uint8 TX_DATA1[D_SIZE]={0x30,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8}; /* transmit buffer in sys ram */
uint8 TX_DATA2[D_SIZE]={0x30,0x03,14,15,16,17,18}; /* transmit buffer in sys ram */
uint8 TX_DATA3[D_SIZE]={21,22,23,24,25,26,27,28}; /* transmit buffer in sys ram */
uint8 RX_DATA1[D_SIZE]= {0}; /* receive buffer in sys ram */
uint8 RX_DATA2[D_SIZE]= {0}; /* receive buffer in sys ram */
uint8 RX_DATA3[D_SIZE]= {0};
/* 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) */
uint32 DMAFlag=0x00;
uint32 DMA_Comp_Flag;
uint32 timer0 = 0;
uint32 CpuCount = 0;
uint8 senderFlag = 0;
g_dmaCTRL g_dmaCTRLPKT; /* dma control packet configuration stack */
void dmaConfigCtrlRxPacket(uint32 sadd,uint32 dadd,uint32 dsize);
/* USER CODE END */
void main(void)
{
/* USER CODE BEGIN (3) */
rtiInit();
rtiStartCounter(rtiCOUNTER_BLOCK0);
rtiDisableNotification(rtiNOTIFICATION_COMPARE0);
canInit();
_enable_IRQ();
canREG1->CTL |= (uint32)(1<<18); // enable DMA for IF2
dmaReqAssign(DMA_CH1, 8); // DMA Configuration and Enable DMA
dmaConfigCtrlRxPacket((uint32)(&TX_DATA1), (uint32)(&(canREG1->IF1DATx[0])), 1);
dmaSetCtrlPacket(DMA_CH1, g_dmaCTRLPKT); // setting dma control packets for transmit
dmaSetChEnable(DMA_CH1, DMA_HW);
dmaEnableInterrupt(DMA_CH1, FTC); // Enable Interrupt after reception of data
while(1)
{
CpuCount = canIsTxMessagePending(canREG1, canMESSAGE_BOX1);
}
/* USER CODE END */
}
/* USER CODE BEGIN (4) */
#pragma WEAK(rtiNotification)
void rtiNotification(uint32 notification)
{
/* enter user code between the USER CODE BEGIN and USER CODE END. */
/* USER CODE BEGIN (9) */
/* Reset the Flag */
timer0 ++;
}
void dmaConfigCtrlRxPacket(uint32 sadd,uint32 dadd,uint32 dsize)
{
g_dmaCTRLPKT.SADD = sadd; /* source address */
g_dmaCTRLPKT.DADD = dadd; /* destination address */
g_dmaCTRLPKT.CHCTRL = 0; /* channel control */
g_dmaCTRLPKT.FRCNT = 1; /* frame count */
g_dmaCTRLPKT.ELCNT = dsize; /* element count */
g_dmaCTRLPKT.ELDOFFSET = 0; /* element destination offset */
g_dmaCTRLPKT.ELSOFFSET = 0; /* element source offset */
g_dmaCTRLPKT.FRDOFFSET = 0; /* frame destination offset */
g_dmaCTRLPKT.FRSOFFSET = 0; /* frame source offset */
g_dmaCTRLPKT.PORTASGN = 4; /* port b */
g_dmaCTRLPKT.RDSIZE = ACCESS_64_BIT; /* read size */
g_dmaCTRLPKT.WRSIZE = ACCESS_64_BIT; /* write size */
g_dmaCTRLPKT.TTYPE = FRAME_TRANSFER ; /* transfer type */
g_dmaCTRLPKT.ADDMODERD = ADDR_FIXED; /* address mode read */
g_dmaCTRLPKT.ADDMODEWR = ADDR_FIXED; /* address mode write */
g_dmaCTRLPKT.AUTOINIT = AUTOINIT_ON; /* autoinit */
}
/* USER CODE END */