Special registers of SDBC (bit-addressable definition method)

Publisher:丝路老君Latest update time:2015-07-16 Source: 51heiKeywords:SDBC Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
'AT89X52.BI
'For 52 compatible MCU
'Const variables and Const variables are calculated at compile time
'By Wan Zhiyuan, sdbc
'Define bit-addressable data types
Type SFR_BIT_A
	Dim SFR_BIT_A As sfr 
	'Define the byte address sfr. If there is a variable with the same name as Type in Type, the compiler will treat it as the default variable
	'For example, if there is SFR_BIT_A in this type, then the external address for this class is actually the address for this variable
	'For example, Dim P0 As SFR_BIT_A at &H80, then P0=0 is equivalent to MOV #80H,0.
	'Then if you need a numeric variable name, you need to add $ in front of it, but if you reference it outside the class/type, you don't need to do that. The with statement also needs it.
	'Similar to P0.0=1. With P0.$0=1 End With
	'Address declarations in type will be fixed at compile time, similar to declaring P0 at 0x80, then $0~$7 are fixed to 0x80~0x87
	Dim $0 As sbit at &SFR_BIT_A
	Dim $1 As sbit at &SFR_BIT_A+1
	Dim $2 As sbit at &SFR_BIT_A+2
	Dim $3 As sbit at &SFR_BIT_A+3
	Dim $4 As sbit at &SFR_BIT_A+4
	Dim $5 As sbit at &SFR_BIT_A+5
	Dim $6 As sbit at &SFR_BIT_A+6
	Dim $7 As sbit at &SFR_BIT_A+7
End Type

'IO port definition
Dim P0 As SFR_BIT_A at &H80' declare P0 at position 0x80
Dim P1 As SFR_BIT_A at &H90' declare P1 at position 0x90
Dim P2 As SFR_BIT_A at &HA0' declare P2 at position 0xA0
Dim P3 As SFR_BIT_A at &HB0' declare P3 at 0xB0
'IO port definition ends
Keywords:SDBC Reference address:Special registers of SDBC (bit-addressable definition method)

Previous article:Finally, I have figured out the 12232 microcontroller driver.
Next article:STC89 series header files used by SDCC

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号