📄 main_ex2.c
字号:
/*C**************************************************************************
* Main_ex2.c
*----------------------------------------------------------------------------
* Copyright (c) 2002 Atmel.
*----------------------------------------------------------------------------
*----------------------------------------------------------------------------
* PURPOSE:
* The goal of this exercice is to learn How to use the CAN_lib to start
* quikly a CAN emission.
*
*****************************************************************************/
/*_____ I N C L U D E S ____________________________________________________*/
#include "config.h"
#include "compiler.h"
#include "can_lib.h"
#define BRP_100k 0x05
#define SJW_100k 0x00
#define PRS_100k 0x01
#define PHS2_100k 0x03
#define PHS1_100k 0x02
void main(void)
{
can_data_t xdata can_data = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88};
can_msg_t xdata can_tx = {STD_ID(0x55), CONF_NOIDE | CONF_DLC_8 , can_data};
/*________________________________________*/
/*_____ CAN CONTROLLER CONFIGURATION _____*/
/*________________________________________*/
CAN_CONTROLLER_RESET;
RazAllMailbox();
CanSetBRP (BRP_100k);
CanSetSJW (SJW_100k);
CanSetPRS (PRS_100k);
CanSetPHS2 (PHS2_100k);
CanSetPHS1 (PHS1_100k);
CAN_CONTROLLER_ENABLE;
/*____________________________________________________________*/
/*_____ CONFIGURE THE MESSAGE OBJECT 1 TO SEND A MESSAGE _____*/
/*____________________________________________________________*/
CAN_SET_CHANNEL(CHANNEL_1);
can_tx_id = can_tx.id;
conf_tx = can_tx.ctrl;
pt_candata_tx = can_tx.pt_donne;
while(P3_3 !=0);
SendCanMsg();
// while((CANSTCH&0x40)!=0x40);
// CANCONCH = 0x00;
while(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -