⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme.txt

📁 在Freescale HCS12中使用I2C总线源码
💻 TXT
字号:
Using the s12_ header files
===========================

Module declaration
------------------
Variables of a hardware module type can be declared for a specific linker segment:

#pragma DATA_SEG S12_TIMER 
    tTIMER		Timer;

Address allocation is then done in the linker command file. 
Has the advantage that the source code doesn't have to change if the module mapping is changed.

peripherals.h has external declarations for the following modules:
 	
Regs
Crg
Timer
Pim 
Can0
Can1
Can2
Can3
Can4
Atd0
Atd1
Pwm
Sci0
Sci1
Spi0
Spi1
Spi2								
Flash
Eeprom
Iic
Page
Bdlc								

Examples of accessing registers
-------------------------------
Byte register in s12_timer.h
	Timer.tscr1.byte = 0x12;
	
Bit in a timer register
	Timer.tscr1.bit.ten = 1;
	
Multiple bits in a timer register
	Timer.tscr1.byte |= (TEN|TFFCA);
	
Word register in s12_timer.h
	Timer.tcnt.word = 0x1234;


Locating header file details in a Code Warrior project
------------------------------------------------------
A quick way to view a header file definition is: 
right click on the first part of a variable in your source code (e.g. Regs.)
select 'Go to variable definition of Regs'
right click on on the type qualifier, tRegister (in this example)
select 'Go to class declaration of tREGISTER' and the header file should opens.
If you then want to see details of an individual register e.g. misc:
right click on tMISC
select 'Go to class declaration of tMISC' and you should be at the bottom of it's declaration.


s12_timer.h exceptions
----------------------
registers   : timer input capture/output compare registers
implemented : array tc[8] of words, 
usage       : Timer.tc[n].word

registers   : timer input capture holding registers
implemented : array tch[4] of words
usage       : Timer.tch[n].word


s12_pwm.h exceptions
--------------------
registers   : pwm channel counters
implemented : array pwmcnt[8] of bytes
access      : Pwm.pwmcnt[n].byte

registers   : pwm channel period counters
implemented : array pwmper[8] of bytes
access      : Pwm.pwmper[n].byte

registers   : pwm channel duty counters
implemented : array pwmdty[8] of bytes
access      : Pwm.pwmdty[n].byte


s12_mscan.h exceptions
----------------------
Complex unions for msCAN ID filter & buffers.

registers   : identifier acceptance/mask registers
implemented : array canid[2] of tCID (ID STRUCTURE)
access      : Can0.canid[0].canidar.l, Can0.canid[0].canidmr.w[1]

registers   : foreground receive buffer
implemented : BUFFER STRUCTURE -
access      : Can0.rxbuf.dsr[0], Can0.rxbuf.tsr, Can0.rxbuf.id.w[0]

registers   : foreground transmit buffer
implemented : BUFFER STRUCTURE 
access      : Can0.txbuf.dsr[0], Can0.txbuf.dlr, Can0.txbuf.id.w[0]


s12_atd.h exceptions
--------------------
registers   : atd result registers
implemented : array atddr[8] of tADDR
access      : atd0.atddr[0].word, 
              atd0.atddr[0].datah, atd0.atddr[0].datal


s12_byteflight.h exceptions
---------------------------
registers   : Transmit data registers 
implemented : array bftdata[12] of tREG08
access      : ByteFlight.bftdata[0].byte

registers   : Receive data registers 
implemented : array bfrdata[12] of tREG08
access      : ByteFlight.bfrdata[0].byte

registers   : Receive Fifo data registers 
implemented : array bffdata[12] of tREG08
access      : ByteFlight.bffdata[0].byte

registers   : Message Buffer Control Registers
implemented : array bfbufctl[16] of tBFBUFCTL
access      : ByteFlight.bfbufctl[0].byte, ByteFlight.bfbufctl[0].bit.cfg

Alternatives ways to declare peripheral stuctures
-------------------------------------------------
1) use the non-ANSI @ instruction:
    tTIMER		Timer  @  0x0040;     - Non-ANSI
2) cast the address as a pointer constant to the module:
	#define Timer *(tTIMER *)0x0040   - Less effective debugging support 
   	 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -