📄 main.asm
字号:
;**************************************************************
;* This stationery serves as the framework for a *
;* user application. For a more comprehensive program that *
;* demonstrates the more advanced functionality of this *
;* processor, please see the demonstration applications *
;* located in the examples subdirectory of the *
;* Freescale CodeWarrior for the HC12 Program directory *
;**************************************************************
; export symbols
XDEF Entry, main
; we use export 'Entry' as symbol. This allows us to
; reference 'Entry' either in the linker .prm file
; or from C/C++ later on
XREF __SEG_END_SSTACK ; symbol defined by the linker for the end of the stack
; include derivative specific macros
INCLUDE 'mc9s12dg128.inc'
; variable/data section
MY_EXTENDED_RAM: SECTION
; code section
MyCode: SECTION
main:
Entry:
LDS #__SEG_END_SSTACK
SEI
START: MOVB #$60,IBFD
BSET IBSR,#$10
BSET IBAD,#$40
BCLR IBCR,#$30;从机模式,接收模式
BSET IBCR,#$80;使能IIC
CLI
A_START:
BRSET IBSR,#$20,* ;等待总线空闲
BSET IBCR,#$30 ;主机模式,发送模式
BRCLR IBSR,#$20,* ;总线忙
MOVB #$FE,IBDR ;发送从机地址,(7位地址+0)
BRCLR IBSR,#$80,* ;等待传输完成
BRCLR IBSR,#$02,* ;总线忙
BRSET IBSR,#$01,* ;等待发送应答信号
BSET IBSR,#$02 ;中断标志位清零
LOOP:
JMP LOOP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -