abstract: the maxq-based microcontroller uses data pointers to read and write to sram. this application note describes how to move data from program memory to the sram, and how to access the data from sram using the data pointers.
introductionthis application note describes how to write two words of data to sram, using data pointers dp[0] and bp[offs]. the data is then read back into the maxq's accumulators from sram using the same data pointers, and a logical and is performed on the two registers.
getting startedto begin, you need basic knowledge about the maxq architecture, register map, and instruction set, which can be obtained from the maxq family user's guide or from any maxq-based microcontroller data sheet. a good example is the maxq2000 data sheet. you also need to reference accessing data memory which is in the maxq family user's guide. basic familiarity with assembly language in general, and with maxq assembler in particular, is assumed.
data pointer overviewthere are three data pointers available on a maxq-based microcontroller: dp[0], dp[1], and bp[offs]. each of these data pointers can be configured to either word- or byte-access modes by setting the corresponding bit in the data point control (dpc) register.
name
function
dp[0]
data pointer 0
dp[1]
data pointer 1
bp[offs]
frame pointer base
offs
offset of frame pointer base
dpc
data pointer control
sdps0
sdps1
00b selects dp[0] as active pointer
01b selects dp[1] as active pointer
10b selects bp as active pointer
wbs0
dp[0] word mode wbs0=1, byte mode wbso=0
wbs1
dp[1] word mode wbs1=1, byte mode wbso=0
wbs2
bp word mode wbs2=1, byte mode wbso=0
register
bit position
dp[0]
dp[0] (16 bits)
dp[1]
dp[1] (16 bits)
bp
bp = bp[offs] (16 bits)
offs
-
-
-
-
offs (8 bits)
dpc
dpc (16 bits)
-
-
-
wbs2
wbs1
wbs0
sdps1
sdps0
the three pointers share a single read/write port on the data memory, and thus the user must knowingly activate the desired pointer before accessing memory. this can be done explicitly using the data select bits (sdps2:0; dpc.1:0), or implicitly by writing to the dp[n], bp, or offs register as shown below. any indirect memory access using a data pointer will also set the sdps bits, thus activating the pointer as the active source pointer.
move dpc, #2 ;(explicit) selection of bp as the active pointer
move dp[1], dp[1] ;(implicit) selection of dp[1]; set sdps1: 0=01b
move offs, src ;(implicit) selection of bp; set sdps1=1
move @dp[0],src ;(implicit) selection of dp[0]; set sdps1:0=00b
increment/decrement data pointerdata pointers can be updated using pre- and post-increment/decrement operator with a register or a virtual nul destination. data pointer increment/decrement operation can be done as follows:
move nul, @dp[0]++ ;increment dp[0]
move nul, @dp[1]-- ;decrement dp[1]
move nul, @bp[offs++] ;increment frame pointer base + offset + 1
move @++dp[0], a[1] ;increment address and store a[1] at new address
;note: only the pre-increment/decrement can be ;used
;when writing to memory
move a[1], @dp[1]-- ;reads value from dp[1] and store in a[1] then
;decrement
;note: only the post-increment/decrement can be
;used
;when reading from memory
code example
move 2 words to sram using dp[0]. 5555h is moved to the first word of sram, referenced by int_var1; aaaah is moved to the second word of sram, referenced by int_var2. var_1 and var_2 are read back from sram into accumulator a[0] and a[1].
int_var1 equ 0h ;address of int_var1 to the first byte of sram
int_var2 equ 1h ;address of int_var2 to the second byte of sram
main:
move dpc, #4h ;set dp[0] to word mode
;must be set active before using
move dp[0], #int_var1 ;load address of int_var1 into dp[0]
;also activated dp[0]
move @dp[0], #5555h ;write 5555h to sram at address of int_var1
move dp[0], #int_var2 ;load address into of int_var1 into dp[0]
move @dp[0], #0aaaah ;writes aaaah to sram at address of int_var2
move dp[0], #int_var1 ;load address of int_var1 into dp[0]
move a[0], @dp[0] ;reads from address of int_var1
move dp[0], #int_var2 ;load address of int_var2 into dp[0]
move a[1], @dp[0] ;reads from address of int_var2
move ap, #0 ;select accumulator 0
and a[1] ;and the a[1] and a[0] and store in a[0]
end
move 2 bytes to sram using dp[1]. 55h is moved to the first byte of sram, referenced by int_var1; aah is moved to the second byte of sram, referenced by int_var2. var_1 and var_2 are read back from sram into accumulator a[0] and a[1].
int_var1 equ 0h ;address of int_var1 to the first word of sram
int_var2 equ 1h ;address of int_var2 to the second word of sram
main:
move dpc, #0h ;set dp[1] to byte mode
;must be set active before using
move dp[1], #int_var1 ;load address of int_var1 into dp[1]
;also activated dp[1]
move @dp[1], #55h ;write 55h to sram at address of int_var1
move dp[1], #int_var2 ;load address into of int_var1 into dp[1]
move @dp[1], #0aah ;writes aah to sram at address of int_var2
move dp[1], #int_var1 ;load address of int_var1 into dp[1]
move a[0], @dp[1] ;reads from address of int_var1
move dp[1], #int_var2 ;load address of int_var2 into dp[1]
move a[1], @dp[1] ;reads from address of int_var2
move ap, #0 ;select accumulator 0
and a[1] ;and the a[1] and a[0] and store in a[0]
end
move 2 words to sram using bp[offs]. 5555h is moved to the first word of sram, referenced by int_var1; aaaah is moved to the second word of sram, referenced by int_var2. var_1 and var_2 are read back from sram into accumulator a[0] and a[1].
int_var1 equ 0h ;address of int_var1 to the first word of sram
int_var2 equ 1h ;address of int_var2 to the second word of sram
main:
move dpc, #10h ;set bp[offs] to word mode
move bp, #0h ;sets bp to 0 and activates bp[offs]
move offs, #int_var1 ;load address of int_var1 into offs
move @bp[offs], #5555h ;write to 5555h to sram at address of int_var1
move offs, #int_var2 ;load address into of int_var1 into offs
move @bp[offs], #0aaaah ;writes aaaah to sram at address of int_var2
move offs, #int_var1 ;load address of int_var1 into offs
move a[0], @bp[offs] ;reads from address of int_var1
move offs, #int_var2 ;load address of int_var2 into offs
move a[1], @bp[offs] ;reads from address of int_var2
move ap, #0 ;select accumulator 0
and a[1] ;and the a[1] and a[0] and store in a[0]
end
invalid data pointer instructionthe following are incorrect uses of data pointers:
assembly instruction
problem
solution
move dp[0], dp[0]
move a[1], @dp[0]
move a[2], @dp[1]
data pointer initialized to dp[0]. needs to be reinitialized to dp[1].
move dp[0], dp[0]
move a[1], @dp[0]
move dp[1], dp[1]
move a[2], @dp[1]
move bp[offs], #0h
bp and offs must be initialized separately.
move bp, #0h
move offs, #0h
move @dp[0]++, a[0]
only the pre-increment/decrement can be used.
move @++dp[0], a[0]
move a[0], @++dp[0]
only the post-increment/decrement can be used.
move a[0], @dp[0]--
move @++dp[0], @dp[0]++
unable to increment data pointer and store it using the same data pointer.
move a[1], @dp[0]++
move @++dp[0], a[1]
move @dp[0]++, a[1]
you cannot use post-increment/decrement for a destination.
move @dp[0], a[1]
move nul, @dp[0]++
move a[0], @--dp[0]
you cannot use pre-increment/decrement for a source.
move nul, @dp[0]--
move a[0], @dp[0]
relevant links
maxq home page
maxq family user's guide
maxq2000 user's guide supplement
dallas semiconductor microcontroller support forum
18年电感厂家教你贴片一体成型电感选型方法
一文了解EDA,EDA里的多物理场分析
浅析变频器应用中常见的问题
浅谈智能手机电源管理解决方案趋势与展望
第四代惠普战66锐龙版笔记本正式开售
使用数据指针,以读/写SRAM
MetalogixReplicator是SharePoint文件同步和复制工具
iPhone手机的这些实用隐藏功能,你掌握了吗?
喜报!佛山贺迪获高新技术企业认定
Trias经济模型将是区块链落地实体经济体的重要方向
特斯拉降价深度解析:供需平衡仍为关键
A2B音频总线-车载多媒体功放音频测试
三季度均创新高,Fabless厂商身上发生了什么
炫硕智造:智能制造势在必行
外媒:美国半导体行业将无法幸免于与中国的技术战争
可用于管理进程的整个生命周期的八个Linux命令
工业互联网信息模型基础设施 驱动制造业转型升级
装置比车还贵:谷歌无人驾驶汽车内部揭秘
工信部部长苗圩:5G最关健的是开放合作、全球统一标准
5G+AI推进工业互联网技术攻关,将为经济发展注入活力