本帖最后由 full_stack 于 2020-7-10 22:36 编辑
AC7801x 开发板,MCU型号为 AC78013FDLA,LQFP48
收到开发板就准备测试,
开发环境:
Keil MDK Version 5
AutoChips.AC780x_DFP.1.0.1.pack
硬件方面要有:
12V/5V 电源
下载仿真器
电源接口我找了下,没找到跟板子对应的,
下载器J-Link使用20针牛角座连上不能识别出设备。
搁置了几天,当时也比较忙,
昨天又拿出来,
电源用了12V的开关电源,焊了两根线到背面,
下载器用了DAP飞线到板子上,总算能下载运行了,
打开Keil MDK Version 5,打开Pack Installer,如图
可以看到AC78013FDLA提供的例程是如此之多,
随便选几个例程复制到本地测试,我选择CAN和GPIO的例程,因为考虑到会用这款芯片CAN设备的开发。
while (1)
{
/* Get KEY6 state and Set LED2 state */
if ((s_key6State == GPIO_KEY_RELEASE) && (GPIO_GET_KEY6() == GPIO_KEY_PRESS)) /* Is KEY6 had been pressed */
{
mdelay(10);
if (GPIO_GET_KEY6() == GPIO_KEY_PRESS)
{
s_led2Enable = !s_led2Enable;
GPIO_SET_LED2(s_led2Enable); /* toggle LED2 output */
if (s_key6State == GPIO_KEY_RELEASE)
{
s_key6State = GPIO_KEY_PRESS;
printf("KEY6 press!\r\n");
}
recvFrameCount += CAN_InterruptRecvSendTest(CANx, type);
}
}
else if ((s_key6State == GPIO_KEY_PRESS) && (GPIO_GET_KEY6() == GPIO_KEY_RELEASE)) /* Is KEY6 had been released */
{
s_key6State = GPIO_KEY_RELEASE;
printf("KEY6 release!\r\n");
}
else
{
}
/* Get KEY7 state and Set LED3 state */
if ((s_key7State == GPIO_KEY_RELEASE) && (GPIO_GET_KEY7() == GPIO_KEY_PRESS)) /* Is KEY7 had been pressed */
{
mdelay(10);
if (GPIO_GET_KEY7() == GPIO_KEY_PRESS)
{
s_key7State = GPIO_KEY_PRESS;
s_led3Enable = !s_led3Enable;
GPIO_SET_LED3(s_led3Enable); /* toggle LED3 output */
printf("KEY7 press!\r\n");
}
}
else if ((s_key7State == GPIO_KEY_PRESS) && (GPIO_GET_KEY7() == GPIO_KEY_RELEASE)) /* Is KEY6 had been released */
{
s_key7State = GPIO_KEY_RELEASE;
printf("KEY7 release!\r\n");
}
else
{
}
}
例程选择的CAN_DEMO,主函数用的的GPIO例程,按键KEY6控制LED2灯的时候发送一帧CAN,
CAN_DEMO中由于本来是设置了一段发送逻辑,由主程序500ms发送一次,所以会出现远程帧仍有数据长度的识别,
int32_t CAN_InterruptRecvSendTest(CAN_Type *CANx, CAN_TransmitBufferType type)
{
static CAN_MsgInfoType s_sendMsg = {0};
static uint8_t sendData[8] = {0};
int32_t recv = 0;
uint8_t instance = 0;
instance = CAN_INDEX(CANx);
if (s_recvMsgPool[instance].recvCount > 0)
{
while (s_recvMsgPool[instance].recvCount > 0)
{
recv++;
HandlePoolCanMsg(CANx);
}
}
if (!CAN_IsTransmitBusy(CANx, type))
{
s_sendMsg.ID++;
s_sendMsg.IDE = rand() % 2;
s_sendMsg.RTR = rand() % 2;
s_sendMsg.DLC = rand() % 9;
*(uint32_t *)sendData += 0xf;
*((uint32_t *)sendData + 1) += 0xf;
s_sendMsg.DATA = sendData;
if (0 == CAN_TransmitMessage(CANx, &s_sendMsg, type))
{
g_sendCount[instance]++;
}
}
return recv;
}
不知是接收器检测到RTR位为远程帧,后面的数据部分不接收,还是远程帧没有发送8字节数据。
照我的理解,
如果发送远程帧,那么表示数据长度的寄存器DLC应该是0,并且不应该有8字节的数据发送
如果发送数据帧,不足八字节,那么DLC是几就应该发送几个字节,
不应该一直发8字节,由接收器去自己抉择。
|