DAvE's Project Documentation

Project: 		CL2.0.dav

Controller: 		XC886CLM-8FF
Compiler: 		Keil
Memory Model: 	COMPACT

Date: 			2024/8/22 08:23:16

Please read this document carefully and note
the red-colored hints.

If you miss a file in the generated files list
maybe you have forgotten to select the
initialisation function of the related module.

Generated Files:
			MAIN.H
			MAIN.C
			SHARED_INT.H
			SHARED_INT.C
			IO.H
			IO.C
			T2.H
			T2.C
			WDT.H
			WDT.C
			CAN.H
			CAN.C
			CL2.0.ASM

Project Settings

Macros:
Functions:

	Function:
		void MAIN_vInit(void)
	Description:
		This function initializes the microcontroller. It is
		assumed that the SFRs are in their reset state.
	Returnvalue:
		None
	Parameters:
		None

	Function:
		void main(void)
	Description:
		This is the main function.
	Returnvalue:
		None
	Parameters:
		None

Initialization:

	Configuration of the System Clock:
	- External Osc is selected (configuration is done in the startup file
	'START_XC.A51')
	- PLL Mode, NDIV =  24
	- input frequency is 8 MHz

	*********************************************************************************
	Note : All peripheral related IO configurations are done in the
	respective peripheral modules (alternate functions selection)
	*********************************************************************************

	Initialization of module 'GPIO'

	Initialization of module 'Timer 2'

	Initialization of module 'Watch Dog Timer'

	Initialization of module 'MultiCAN Controller '

	Initialization of  'Shared interrupts'

	Interrupt structure 2 mode 0 is selected.

	Interrupt service routine choice 2 is selected.

Shared Interrupt Routines

Macros:
Functions:

	Function:
		void SHINT_vInit(void)
	Description:
		This function initializes the shared interrupts.
	Returnvalue:
		None
	Parameters:
		None

	Function:
		void SHINT_viXINTR5Isr(void)
	Description:
		This is the service routine for the shared interrupt node
		XINTR5. XINTR5 ISR Node is shared by Timer 2, UART
		Fractional Divider(BRG Interrupt),MultiCAN Node 0 and LIN.
		Depending on the selected module interrupt it is called.
		T2 - Depending on the selected operating mode it is called
		when TF2 is set by an overflow or underflow of the timer 2
		register or when EXF2 is set by a negative transition on
		T2EX.
		UART - It is called after the BRG timer overflows and sets
		the NDOV bit.
		CAN -  It is called for the  Service Request Node 0 of the
		MultiCAN module.
		Please note that you have to add application specific code
		to this function.
	Returnvalue:
		none
	Parameters:
		None

Initialization:

	Configuration of the Shared  Interrupts:
	- Timer 2 Interrupt is Selected

GPIO

Macros:

	Macro:
		IO_ubReadPin(PinName)
	Description:
		This macro returns the status of the chosen portpin.
		Note:
		'PinName' identifies the pin of a bit-addressable port. The
		default names can be changed in the port configuration
		dialog.
	Returnvalue:
		Status of the chosen portpin
	Parameters:
		PinName:
		Pin to be read

	Macro:
		IO_vSetPin(PinName)
	Description:
		The chosen portpin is set to '1'.
		Note:
		'PinName' identifies the pin of a bit-addressable port. The
		default names can be changed in the port configuration
		dialog.
	Returnvalue:
		None
	Parameters:
		PinName:
		Pin to be set to '1'

	Macro:
		IO_vResetPin(PinName)
	Description:
		The chosen portpin is set to '0'.
		Note:
		'PinName' identifies the pin of a bit-addressable port. The
		default names can be changed in the port configuration
		dialog.
	Returnvalue:
		None
	Parameters:
		PinName:
		Pin to be set to '0'

	Macro:
		IO_vTogglePin(PinName)
	Description:
		The chosen portpin will be toggled.
		Note:
		'PinName' identifies the pin of a bit-addressable port. The
		default names can be changed in the port configuration
		dialog.
	Returnvalue:
		None
	Parameters:
		PinName:
		Pin to be toggled
Functions:

	Function:
		void IO_vInit(void)
	Description:
		This is the initialization function of the IO function
		library. It is assumed that the SFRs used by this library
		are in their reset state.
	Returnvalue:
		None
	Parameters:
		None

Initialization:

	***********************************************************************
	Note : All peripheral related IO configurations are done in the
	respective peripheral modules (alternate functions selection)
	
	If no pins are selected DAvE assumes that registers are in default
	settings
	***********************************************************************

	Configuration of Port P0:
	P0.0:
	- is used as general input
	- pull-down device is assigned
	P0.1:
	- is used as general purpose output
	- push/pull output is selected
	- the pin status is low level
	- pull-down device is assigned
	P0.2:
	- is used as general input
	- pull-down device is assigned
	P0.3:
	- is used as general purpose output
	- push/pull output is selected
	- the pin status is low level
	- pull-down device is assigned
	P0.5:
	- is used as general input
	- pull device is disabled (tristate)
	P0.7:
	- is used as general purpose output
	- push/pull output is selected
	- the pin status is low level
	- pull-down device is assigned

	Configuration of Port P1:
	P1.0:
	- is used as alternate input for the MCAN Node 0 Receiver Input
	- pull-up device is assigned
	P1.1:
	- is used as alternate output for the MCAN Node 0 Transmitter Output
	- push/pull output is selected
	- pull-up device is assigned
	P1.2:
	- is used as general input
	- pull-down device is assigned
	P1.3:
	- is used as general input
	- pull-down device is assigned
	P1.4:
	- is used as general input
	- pull-down device is assigned
	P1.5:
	- is used as general input
	- pull-down device is assigned
	P1.7:
	- is used as general input
	- pull-down device is assigned

	Configuration of Port P2:
	P2.0:
	- is used as general input
	- input driver is enabled
	- pull device is disabled (tristate)
	P2.1:
	- is used as general input
	- input driver is enabled
	- pull device is disabled (tristate)
	P2.3:
	- is used as general input
	- input driver is enabled
	- pull device is disabled (tristate)
	P2.4:
	- is used as general input
	- input driver is enabled
	- pull-up device is assigned
	P2.5:
	- is used as general input
	- input driver is enabled
	- pull-up device is assigned

	Configuration of Port P3:
	P3.0:
	- is used as general input
	- pull-up device is assigned
	P3.1:
	- is used as general input
	- pull-up device is assigned
	P3.2:
	- is used as general purpose output
	- push/pull output is selected
	- the pin status is low level
	- pull-down device is assigned
	P3.3:
	- is used as general purpose output
	- push/pull output is selected
	- the pin status is low level
	- pull-down device is assigned
	P3.4:
	- is used as general purpose output
	- push/pull output is selected
	- the pin status is low level
	- pull-down device is assigned
	P3.5:
	- is used as general input
	- pull-down device is assigned
	P3.6:
	- is used as general input
	- pull-up device is assigned
	P3.7:
	- is used as general input
	- pull-up device is assigned

	Configuration of Port P4:
	P4.0:
	- is used as general input
	- pull-down device is assigned
	P4.1:
	- is used as general purpose output
	- push/pull output is selected
	- the pin status is low level
	- pull-down device is assigned
	P4.3:
	- is used as general input
	- pull-down device is assigned

Timer 2

Macros:
Functions:

	Function:
		void T2_vInit(void)
	Description:
		This is the initialization function of the Timer 2 function
		library. It is assumed that the SFRs used by this library
		are in their reset state.
		The following SFRs and SFR fields will be initialized:
		T2_RC2H/RC2L     - reload/capture timer 2 register
		T2_T2H/T2L     -  timer 2 register
		ET2           - timer 2 interrupt enable
		T2_T2MOD         - timer 2 mode register
		CP/RL2        - Capture/Reload select
		EXEN2         - External enable control
		TR2           - Timer2 run control
	Returnvalue:
		None
	Parameters:
		None

Initialization:

	16-bit timer function with automatic reload when timer 2 overflows
	the timer 2 resolution is 1 ?s
	the timer 2 overflow is 1000.000 ?s
	timer 2 interrupt: enabled
	timer 2 will be started

	timer 2 Interrupt enable bit is set in SHINT_vInit() function

Watch Dog Timer

Macros:

	Macro:
		WDT_vRefresh()
	Description:
		This macro refreshes the watchdog timer to the reload
		value. The interrupts are disabled during execution of the
		instructions that set bit WDTRS.
		Note: The user has to take care that this macro is called
		before expiry of the watchdog timer.
		pls refer to the Note on WDT_vInit function Description
	Returnvalue:
		None
	Parameters:
		None
Functions:

	Function:
		void WDT_vInit(void)
	Description:
		This is the initialization function of the 'Watch Dog
		Timer' function library. It is assumed that the SFRs used
		by this library are in their reset state.
		The watchdog timer is used.
		The following SFR fields will be initialized:
		WDTREL - WDT reload value
		WDTIN  - WDT input frequency selection
		Then the watchdog timer will be refreshed.
		Note: The user has to take care that RMAP bit in SYSCON0 is
		to be set while using the registers of Watch dog timer.
		Registers are WDTCON,WDTWINB,WDTREL,WDTH,WDTL
	Returnvalue:
		None
	Parameters:
		None

	Function:
		void WDT_vDisable(void)
	Description:
		This function disables the WDT.
		pls refer to the Note on WDT_vInit function Description
	Returnvalue:
		None
	Parameters:
		None

Initialization:

	the watchdog timer is used and it is enabled in INIT function,user has
	to take care of WDT refresh
	the RMAP bit of SYSCON0 is set
	the input frequency is fSYS/128
	the watchdog timer reload value is 0xDB
	the watchdog timeout period is 50 ms

MultiCAN Controller

Macros:

	Macro:
		CAN_vReadEN()
	Description:
		This macro enables Read mode (CAN Address/Data Control
		Register).
	Returnvalue:
		None
	Parameters:
		None

	Macro:
		CAN_vWriteEN(ubyte ubDCtrl)
	Description:
		This macro enables Write mode (CAN Address/Data Control
		Register).
	Returnvalue:
		None
	Parameters:
		ubDCtrl:
		Data Control Flags

	Macro:
		CAN_vWriteCANAddress(uword uwAdr)
	Description:
		This macro writes 16-bit CAN address to CAN Address
		Register Low and High respectively.
	Returnvalue:
		None
	Parameters:
		uwAdr:
		16-bit Address

	Macro:
		CAN_vWriteCANData(ulong ulValue)
	Description:
		This macro writes 32-bit Data to CAN Data Register's
		0-3respectively.
		Note:
		Write Process :
		->Write the address of the MultiCAN kernel register to the
		CAN_ADL and CAN_ADH registers.
		use macro : CAN_vWriteCANAddress.
		->Write the data to the
		CAN_DATA0/CAN_DATA1/CAN_DATA2/CAN_DATA3 registers.
		->Write the register CAN_ADCON, including setting the valid
		bit of the data registers and setting register bit RWEN to
		1.
		->The valid data will be written to the MultiCAN kernel
		only once. Register bit BSY will become 1.
		->When Register bit BSY becomes 0, the transmission is
		finished.
	Returnvalue:
		None
	Parameters:
		ulValue:
		32-bit Data

	Macro:
		CAN_pushAMRegs/_popAMRegs()
	Description:
		The macro CAN_pushAMRegs() PUSH the CAN Access Mediator
		Registers.
		The macro CAN_popAMRegs() POP the CAN Access Mediator
		Registers.
		Note:
		This macro is used in CAN ISR/Function's to protect Access
		Mediator Register
		MultiCAN Access Mediator Registers:
		ADL, ADH, DATA0, DATA1, DATA2, DATA3.
		The _push_/_pop_ routine inserts a PUSH/POP instruction
		into the program saving the contents of the Special
		Function Register(sfr) on the Stack.
	Returnvalue:
		None
	Parameters:
		None
Functions:

	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 their reset state.
	Returnvalue:
		None
	Parameters:
		None

	Function:
		void CAN_vWriteAMData(ulong ulValue)
	Description:
		This function writes 32-bit Data to CAN Data Register's
		0-3respectively.
		Note:
		Write Process :
		->Write the address of the MultiCAN kernel register to the
		CAN_ADL and CAN_ADH registers.
		use macro : CAN_vWriteCANAddress.
		->Write the data to the
		CAN_DATA0/CAN_DATA1/CAN_DATA2/CAN_DATA3 registers.
		->Write the register CAN_ADCON, including setting the valid
		bit of the data registers and setting register bit RWEN to
		1.
		->The valid data will be written to the MultiCAN kernel
		only once. Register bit BSY will become 1.
		->When Register bit BSY becomes 0, the transmission is
		finished.
	Returnvalue:
		None
	Parameters:
		ulValue:
		32-bit Data

	Function:
		void CAN_vSetListCommand(ulong ulVal)
	Description:
		This function write's 32-bit Data to CAN_PANCTR Register.
	Returnvalue:
		None
	Parameters:
		ulVal:
		32-bit Data

	Function:
		void CAN_vGetMsgObj(ubyte ubObjNr, stCAN_SWObj *pstObj)
	Description:
		This function fills the forwarded SW message object with
		the content of the chosen HW message object.
		The structure of the SW message object is defined in the
		header file CAN.H (see stCAN_SWObj).
	Returnvalue:
		None
	Parameters:
		ubObjNr:
		Number of the message object to be read (0-31)
		*pstObj:
		Pointer on a message object to be filled by this function

	Function:
		ubyte CAN_ubRequestMsgObj(ubyte ubObjNr)
	Description:
		If a TRANSMIT OBJECT is to be reconfigured it must first be
		accessed. The access to the transmit object is exclusive.
		This function checks whether the choosen message object is
		still executing a transmit request, or if the object can be
		accessed exclusively.
		After the message object is reserved, it can be
		reconfigured by using the function CAN_vConfigMsgObj or
		CAN_vLoadData.
		Both functions enable access to the object for the CAN
		controller.
		By calling the function CAN_vTransmit transfering of data
		is started.
	Returnvalue:
		0 message object is busy (a transfer is active), else 1
	Parameters:
		ubObjNr:
		Number of the message object (0-31)

	Function:
		ubyte CAN_ubNewData(ubyte ubObjNr)
	Description:
		This function checks whether the selected RECEIVE OBJECT
		has received a new message. If so the function returns the
		value '1'.
	Returnvalue:
		1 the message object has received a new message, else 0
	Parameters:
		ubObjNr:
		Number of the message object (0-31)

	Function:
		void CAN_vTransmit(ubyte ubObjNr)
	Description:
		This function triggers the CAN controller to send the
		selected message.
		If the selected message object is a TRANSMIT OBJECT then
		this function triggers the sending of a data frame. If
		however the selected message object is a RECEIVE OBJECT
		this function triggers the sending of a remote frame.
	Returnvalue:
		None
	Parameters:
		ubObjNr:
		Number of the message object (0-31)

	Function:
		void CAN_vLoadData(ubyte ubObjNr, ulong *ulpubData)
	Description:
		If a hardware TRANSMIT OBJECT has to be loaded with data
		but not with a new identifier, this function may be used
		instead of the function CAN_vConfigMsgObj. The message
		object should be accessed by calling the function
		CAN_ubRequestMsgObj before calling this function. This
		prevents the CAN controller from working with invalid data.
	Returnvalue:
		None
	Parameters:
		ubObjNr:
		Number of the message object to be configured (0-31)
		*ulpubData:
		Pointer on a data buffer

	Function:
		void CAN_vReleaseObj(ubyte ubObjNr)
	Description:
		This function resets the NEWDAT flag of the selected
		RECEIVE OBJECT, so that the CAN controller have access to
		it. This function must be called if the function
		CAN_ubNewData detects, that new data are present in the
		message object and the actual data have been read by
		calling the function CAN_vGetMsgObj.
	Returnvalue:
		None
	Parameters:
		ubObjNr:
		Number of the message object (0-31)

Initialization:

	Configuration of the Module Clock:
	- the CAN module clock = 48.00 MHz
	- FCLK runs at 2 times the frequency of PCLK.

	- CMCON - Clock Control Register is Configured in MAIN_vInit

	Configuration of CAN Node 0:

	General Configuration of the Node 0:
	- set INIT and CCE

	- load NODE 0 interrupt pointer register

	Configuration of the used CAN Input Port Pins:
	- Pin P1.0 is used as RXDC0_0 input

	- Loop-back mode is disabled

	Configuration of the Node 0 Baud Rate:
	- required baud rate = 100.000 kbaud
	- real baud rate     = 100.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

	Configuration of the Node 0 Error Counter:
	- the error warning threshold value (warning level) is 96

	Configuration of the Frame Counter:
	- Frame Counter Mode: the counter is incremented upon the reception
	and transmission of frames
	- frame counter: 0x0000

	Configuration of CAN Node 1:

	General Configuration of the Node 1:
	- set INIT and CCE

	Configuration of the used CAN Output Port Pins:
	Pin P1.1 is used as TXDC0_0 Output
	- NODE1 TXD Pin's are not used

	Configuration of the CAN Message Object List Structure:

	Allocate MOs for list 1:

	Configuration of the CAN Message Objects 0 - 31:
	Configuration of Message Object 0:
	- message object 0 is not valid
	Configuration of Message Object 1:
	- message object 1 is not valid
	Configuration of Message Object 2:
	- message object 2 is not valid
	Configuration of Message Object 3:
	- message object 3 is not valid
	Configuration of Message Object 4:
	- message object 4 is not valid
	Configuration of Message Object 5:
	- message object 5 is valid
	- message object is used as receive object
	- this message object is assigned to list 1 (node 0)

	- priority class 3; transmit acceptance filtering is based on the list
	order (like class 1)
	- extended 29-bit identifier
	- identifier 29-bit:      0x00000003

	- only accept receive frames with matching IDE bit
	- acceptance mask 29-bit: 0x1FFFFFFF

	- use message pending register 0 bit position 5

	- this object is a STANDARD MESSAGE OBJECT
	- 8 valid data bytes

	Configuration of Message Object 6:
	- message object 6 is valid
	- message object is used as transmit object
	- this message object is assigned to list 1 (node 0)

	- priority class 3; transmit acceptance filtering is based on the list
	order (like class 1)
	- standard 11-bit identifier
	- identifier 11-bit:      0x7F1

	- only accept receive frames with matching IDE bit
	- acceptance mask 11-bit: 0x7FF

	- use message pending register 0 bit position 6

	- this object is a STANDARD MESSAGE OBJECT
	- 8 valid data bytes

	Configuration of Message Object 7:
	- message object 7 is valid
	- message object is used as receive object
	- this message object is assigned to list 1 (node 0)

	- priority class 3; transmit acceptance filtering is based on the list
	order (like class 1)
	- standard 11-bit identifier
	- identifier 11-bit:      0x7F2

	- only accept receive frames with matching IDE bit
	- acceptance mask 11-bit: 0x7FF

	- use message pending register 0 bit position 7

	- this object is a STANDARD MESSAGE OBJECT
	- 8 valid data bytes

	Configuration of Message Object 8:
	- message object 8 is valid
	- message object is used as receive object
	- this message object is assigned to list 1 (node 0)

	- priority class 3; transmit acceptance filtering is based on the list
	order (like class 1)
	- standard 11-bit identifier
	- identifier 11-bit:      0x7F3

	- only accept receive frames with matching IDE bit
	- acceptance mask 11-bit: 0x7FF

	- use message pending register 0 bit position 8

	- this object is a STANDARD MESSAGE OBJECT
	- 8 valid data bytes

	Configuration of Message Object 9:
	- message object 9 is valid
	- message object is used as transmit object
	- this message object is assigned to list 1 (node 0)

	- priority class 3; transmit acceptance filtering is based on the list
	order (like class 1)
	- extended 29-bit identifier
	- identifier 29-bit:      0x1FFFFFF0

	- only accept receive frames with matching IDE bit
	- acceptance mask 29-bit: 0x1FFFFFFF

	- use message pending register 0 bit position 9

	- this object is a STANDARD MESSAGE OBJECT
	- 8 valid data bytes

	Configuration of Message Object 10:
	- message object 10 is valid
	- message object is used as transmit object
	- this message object is assigned to list 1 (node 0)

	- priority class 3; transmit acceptance filtering is based on the list
	order (like class 1)
	- extended 29-bit identifier
	- identifier 29-bit:      0x11000000

	- only accept receive frames with matching IDE bit
	- acceptance mask 29-bit: 0x1FFFFFFF

	- use message pending register 0 bit position 10

	- this object is a STANDARD MESSAGE OBJECT
	- 8 valid data bytes

	Configuration of Message Object 11:
	- message object 11 is not valid
	Configuration of Message Object 12:
	- message object 12 is not valid
	Configuration of Message Object 13:
	- message object 13 is not valid
	Configuration of Message Object 14:
	- message object 14 is not valid
	Configuration of Message Object 15:
	- message object 15 is not valid
	Configuration of Message Object 16:
	- message object 16 is not valid
	Configuration of Message Object 17:
	- message object 17 is not valid
	Configuration of Message Object 18:
	- message object 18 is not valid
	Configuration of Message Object 19:
	- message object 19 is not valid
	Configuration of Message Object 20:
	- message object 20 is not valid
	Configuration of Message Object 21:
	- message object 21 is not valid
	Configuration of Message Object 22:
	- message object 22 is not valid
	Configuration of Message Object 23:
	- message object 23 is not valid
	Configuration of Message Object 24:
	- message object 24 is not valid
	Configuration of Message Object 25:
	- message object 25 is not valid
	Configuration of Message Object 26:
	- message object 26 is not valid
	Configuration of Message Object 27:
	- message object 27 is not valid
	Configuration of Message Object 28:
	- message object 28 is not valid
	Configuration of Message Object 29:
	- message object 29 is not valid
	Configuration of Message Object 30:
	- message object 30 is not valid
	Configuration of Message Object 31:
	- message object 31 is not valid

	Configuration of the Interrupts:
	- CAN interrupt node 0 is disabled
	- CAN interrupt node 1 is disabled
	- CAN interrupt node 2 is disabled
	- CAN interrupt node 3 is disabled
	- CAN interrupt node 4 is disabled
	- CAN interrupt node 5 is disabled
	- CAN interrupt node 6 is disabled
	- CAN interrupt node 7 is disabled