//****************************************************************************
// @Module MultiCAN Module (CAN)
// @Filename CAN.c
// @Project Dave.dav
//----------------------------------------------------------------------------
// @Controller Infineon XC2287M-104F80
//
// @Compiler Tasking Viper
//
// @Codegenerator 2.0
//
// @Description This file contains functions that use the CAN module.
//
//----------------------------------------------------------------------------
// @Date 2010-6-3 10:01:43
//
//****************************************************************************
// USER CODE BEGIN (CAN_General,1)
// USER CODE END
//****************************************************************************
// @Project Includes
//****************************************************************************
#include "XC22xxMREGS.h"
#include "CAN.h"
#include "wave.h"
PF_Error_AddERROR m_pError_3;
PF_CANReceiveInterruptProcess m_pInterruptProcess_2;
unsigned int m_startTimer_3;
unsigned int m_timerCounter_3;
// USER CODE BEGIN (CAN_General,2)
// USER CODE END
//****************************************************************************
// @Macros
//****************************************************************************
// USER CODE BEGIN (CAN_General,3)
// USER CODE END
//****************************************************************************
// @Defines
//****************************************************************************
// USER CODE BEGIN (CAN_General,4)
// USER CODE END
//****************************************************************************
// @Typedefs
//****************************************************************************
// USER CODE BEGIN (CAN_General,5)
// USER CODE END
//****************************************************************************
// @Imported Global Variables
//****************************************************************************
// USER CODE BEGIN (CAN_General,6)
// USER CODE END
//****************************************************************************
// @Global Variables
//****************************************************************************
// USER CODE BEGIN (CAN_General,7)
// USER CODE END
//****************************************************************************
// @External Prototypes
//****************************************************************************
// USER CODE BEGIN (CAN_General,8)
// USER CODE END
//****************************************************************************
// @Prototypes Of Local Functions
//****************************************************************************
// USER CODE BEGIN (CAN_General,9)
// USER CODE END
//****************************************************************************
// @Function void CAN_vInit(void)
//
//----------------------------------------------------------------------------
// @Description This is the initialization function of the CAN function
// library. It is assumed that the SFRs used by this library
// are in reset state.
//
//----------------------------------------------------------------------------
// @Returnvalue None
//
//----------------------------------------------------------------------------
// @Parameters None
//
//----------------------------------------------------------------------------
// @Date 2010-6-3
//
//****************************************************************************
static void CAN_vInit(void);
// USER CODE BEGIN (Init,1)
// USER CODE END
void CAN_Init(PF_Error_AddERROR pfError,PF_CANReceiveInterruptProcess pfInterrupt,unsigned int timerCounter)
{
m_pError_3=pfError;
m_pInterruptProcess_2=pfInterrupt;
m_timerCounter_3=timerCounter;
CAN_vInit();
}
static void CAN_vInit(void)
{
// USER CODE BEGIN (Init,2)
// USER CODE END
/// -----------------------------------------------------------------------
/// Configuration of Kernel State Configuration Register:
/// -----------------------------------------------------------------------
/// - Enable the CAN module(MODEN)
/// - Enable Bit Protection for MODEN
MCAN_KSCCFG = 0x0003; // load Kernel State Configuration Register
_nop(); // one cycle delay
_nop(); // one cycle delay
/// -----------------------------------------------------------------------
/// Configuration of the Module Clock:
/// -----------------------------------------------------------------------
/// - the CAN module clock = 20.00 MHz
/// - Normal divider mode selected
CAN_FDRL = 0x43FE; // load Fractional Divider Register
/// -----------------------------------------------------------------------
/// Panel Control
/// -----------------------------------------------------------------------
/// - wait until Panel has finished the initialisation
while(CAN_PANCTRL & CAN_PANCTR_BUSY){ // wait until Panel has finished
// the initialisation
}
/// -----------------------------------------------------------------------
/// Configuration of CAN Node 0:
/// -----------------------------------------------------------------------
/// General Configuration of the Node 0:
/// - set INIT and CCE
CAN_NCR0 = 0x0041; // load NODE 0 control register[15-0]
/// - load NODE 0 interrupt pointer register
CAN_NIPR0 = 0x0000; // load NIPR0_LECINP, ALINP, CFCINP and TRINP
/// Configuration of the used CAN Port Pins:
/// - Loop-back mode is disabled
/// - P2.0 is used for CAN0 Receive input(RXDC0C)
/// - P2.1 is used for CAN0 Transmit output(TXDC0C)
P2_IOCR01 = 0x0090; //set direction register
CAN_NPCR0 = 0x0002; // load node0 port control register
/// Configuration of the Node 0 Baud Rate:
/// - required baud rate = 500.000 kbaud
/// - real baud rate = 500.000 kbaud
/// - sample point = 60.00 %
/// - there are 5 time quanta before sample point
/// - there are 4 time quanta after sample point
/// - the (re)synchronization jump width is 2 time quanta
CAN_NBTR0L = 0x3443; // load NBTR0_DIV8, TSEG2, TSEG1, SJW and BRP
/// Configuration of the Node 0 Error Counter:
/// - the error warning threshold value (warning level) is 96
CAN_NECNT0H = 0x0060; // load NECNT0_EWRNLVL register
CAN_NECNT0L = 0x0000;
/// Configuration of the Frame Counter:
/// - Frame Counter Mode: the counter is incremented upon the reception
/// and transmission of frames
/// - frame counter: 0x0000
CAN_NFCR0H = 0x0000; // load NFCR0_CFCOV, CFCIE, CFMOD, CFSEL
CAN_NFCR0L = 0x0000; // load NFCR0_CFC
/// -----------------------------------------------------------------------
/// Configuration of CAN Node 1:
/// -----------------------------------------------------------------------
/// General Configuration of the Node 1:
/// - set INIT and CCE
CAN_NCR1 = 0x0041; // load NODE 1 control register[15-0]
/// - load NODE 1 interrupt pointer register
CAN_NIPR1 = 0x0000; // load NIPR1_LECINP, ALINP, CFCINP and TRINP
/// Configuration of the used CAN Port Pins:
/// - Loop-back mode is disabled
/// - P2.7 is used for CAN1 Receive input(RXDC1C)
/// - P2.2 is used for CAN1 Transmit output(TXDC1B)
P2_IOCR02 = 0x0090; //set direction register
CAN_NPCR1 = 0x0002; // load node1 port control register
/// Configuration of the Node 1 Baud Rate:
/// - required baud rate = 500.000 kbaud
/// - real baud rate = 500.000 kb
没有合适的资源?快使用搜索试试~ 我知道了~
BMS 主控板代码
共121个文件
h:57个
c:48个
launch:2个
3星 · 超过75%的资源 需积分: 49 260 下载量 135 浏览量
2017-09-15
13:57:55
上传
评论 19
收藏 376KB RAR 举报
温馨提示
BMS 主控板代码,可以找到有用的模块参考,个国内电池管理系统(bms)的源码,主机用的是XC2287M,解决方案C语言程序源码 有电压、电流等采集方案源代码
资源推荐
资源详情
资源评论
收起资源包目录
BMS 主控板代码 (121个子文件)
CAN.c 214KB
SCS.c 59KB
Event.c 51KB
cstart.c 16KB
Error.c 12KB
Battery.c 8KB
QQ_Test.c 6KB
CMD_CALL.c 5KB
EERPOM_Task.c 5KB
MainProcess.c 5KB
Cmd_test.c 4KB
Cmd.c 4KB
Wave.c 3KB
Frequency.c 3KB
QuantityChange.c 3KB
Battery_Task.c 3KB
BMS_Flag.c 3KB
ShareMemery.c 3KB
CMD_JMP.c 3KB
CMD_Code.c 3KB
CANSendBuffer.c 2KB
CMD_Math.c 2KB
CAN_Task.c 2KB
Shell.c 2KB
Current.c 2KB
CMD_Print.c 2KB
BMS_CAN.c 2KB
Task.c 2KB
Timer_Manager.c 2KB
TaskProcess.c 1KB
Event_Test.c 1KB
main.c 1KB
CMD_Echo.c 1KB
CMD_In.c 1KB
Current_Task.c 1KB
CMD_Scan.c 1KB
WDT.c 994B
DHAB.c 956B
File.c 783B
Calendar_Task.c 657B
CMD_Define.c 643B
Timer_Test.c 228B
Module_TimerTest.c 98B
CMD_Restart.c 94B
CMD_Search.c 93B
CMD_LCALL.c 92B
ADC_Task.c 90B
Tempture.c 90B
.cproject 23KB
XC22xxMREGS.h 818KB
XC22xxMREGS.h 818KB
Event.h 18KB
cstart.h 11KB
SCS.h 8KB
CAN.h 8KB
BMS_CAN.h 4KB
CAN_3.h 3KB
CAN.h 3KB
Wave.h 2KB
Calendar.h 2KB
Error.h 2KB
EEPROM_Task.h 1KB
ShareMemery.h 1KB
EEPROM.h 1KB
CMD_JMP.h 973B
Task.h 955B
CMD_Call.h 828B
CMD_Math.h 720B
Relay.h 700B
ADC.h 615B
CMD.h 601B
CANSendBuffer.h 537B
MainProcess.h 506B
Timer.h 388B
Frequency.h 386B
TaskProcess.h 367B
RTC.h 347B
Shell.h 326B
CMD_Code.h 325B
Battery.h 319B
WDT.h 317B
CAN_Task.h 285B
Current.h 274B
QQ_Test.h 261B
Battery_Task.h 256B
CMD_Print.h 254B
CMD_Echo.h 250B
BMS_Flag.h 248B
CMD_Scan.h 248B
CMD_Define.h 245B
Timer_Manager.h 242B
MAIN.h 237B
CMD_In.h 236B
QuantityChange.h 219B
Calendar_Task.h 210B
Timer_Test.h 202B
Event_Test.h 200B
Current_Task.h 199B
DHAB.H 188B
Cmd_test.h 179B
共 121 条
- 1
- 2
资源评论
- SJMZ_662018-11-29还可以学习一下
老试
- 粉丝: 3
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功