📄 bldc1-w.asm
字号:
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; 产品名称: 高速脱水机控制器
; 产品型号: BLDC1-W
;
; 产品主要电气参数:
;
; 工作电压: DC36V(XX——53.5V)
; 工作电流: 7A
; BLDC转速: 3240rpm = 54 HZ
; 机器谐振点:200rpm
;
; 软件:
; File name: BLDC1-W
; 控制器:ATmega48-20AU
;
; Device Flash EEPROM RAM Interrupt Vector Size
;
; ATmega48 4K Bytes 256 Bytes 512 Bytes 1 instruction word/vector
; ATmega88 8K Bytes 512 Bytes 1K Bytes 1 instruction word/vector
; ATmega168 16K Bytes 512 Bytes 1K Bytes 2 instruction words/vector
;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; 功能描述
;
; 当开关闭合后, 驱动BLDC以3240rpm顺时针旋转6分钟
;
; 开关断开后,停止驱动,吸合电磁锁,刹车25S后或旋转停止后释放电磁锁
;
; 或者6分钟后,停止驱动,吸合电磁锁,刹车25S后或旋转停止后释放电磁锁
;
; 脱水时开启排水阀
;
;----------------------------------------------------------------------------------------
; 该马达定子共有12个线圈,转子有8个4对磁极
; 4X6=24个脉冲为一圈
; 当运转速度为3240rpm = 54 HZ,脉冲宽度为:
;
; 1000 000/(54*24)=771.6uS
; PWM周期=1000 000/20 000=50uS
; 每个脉冲有771.6/50=15.4个中断
;
; rpm = (60*1000 000)/(FILTERED_T*2*24)=1250000/FILTERED_T
; rpm = 60*SPEED/4= 15*SPEED
;
;----------------------------------------------------------------------------------------
; 动作定义:
;
; 刹车=BLDC的三个线圈通过NMOS管对地短路
;
; 待机= 开关 6分钟脱水结束
;
; 1 X
; 0 脱水结束
; 待机时,低端3个NMOS都导通,对高端驱动电路充电
;
;----------------------------------------------------------------------------------------
;资源规划:
;
; T0 = PWM,速度调节
; T1 = MOTOR CONTROL TIMER
; T2 = SYSTEM TIMER
;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;熔丝字节:
;
;熔丝位高字节
;
;High Fuse Byte Bit No Description Default Value
;
;RSTDISBL 7 External Reset Disable 1 (unprogrammed)
;DWEN 6 debugWIRE Enable 1 (unprogrammed)
;SPIEN 5 Enable Serial Program 0 (programmed, SPI programming enabled)
; and Data Downloading
;WDTON 4 Watchdog Timer Always On 1 (unprogrammed)
;EESAVE 3 EEPROM memory is preserved 1 (unprogrammed), EEPROM not reserved
; through the Chip Erase
;BODLEVEL2 2 Brown-out Detector trigger level 1 (unprogrammed)
;BODLEVEL1 1 Brown-out Detector trigger level 1 (unprogrammed)
;BODLEVEL0 0 Brown-out Detector trigger level 1 (unprogrammed)
;
;熔丝位低字节
;
;Low Fuse Byte Bit No Description Default Value
;
;CKDIV8 7 Divide clock by 8 0 (programmed)
;CKOUT 6 Clock output 1 (unprogrammed)
;SUT1 5 Select start-up time 1 (unprogrammed)
;SUT0 4 Select start-up time 0 (programmed)
;CKSEL3 3 Select Clock source 0 (programmed)
;CKSEL2 2 Select Clock source 0 (programmed)
;CKSEL1 1 Select Clock source 1 (unprogrammed)
;CKSEL0 0 Select Clock source 0 (programmed)
;
;Device Clocking Option CKSEL3..0
;Low Power Crystal Oscillator 1111 - 1000
;Full Swing Crystal Oscillator 0111 - 0110
;Low Frequency Crystal Oscillator 0101 - 0100
;Internal 128 kHz RC Oscillator 0011
;Calibrated Internal RC Oscillator 0010
;External Clock 0000
;
;Reserved 0001
;
;The device is shipped with internal RC oscillator at 8.0MHz and with the fuse CKDIV8 programmed,
;resulting in 1.0MHz system clock. The startup time is set to maximum and time-out
;period enabled. (CKSEL = "0010", SUT = "10", CKDIV8 = "0"). The default setting ensures that
;all users can make their desired clock source setting using any available programming interface.
;
;OSCCAL – Oscillator Calibration Register
;
;Note that this oscillator is used to time EEPROM and Flash write accesses, and these write
;times will be affected accordingly. If the EEPROM or Flash are written, do not calibrate to more
;than 8.8 MHz. Otherwise, the EEPROM or Flash write may fail.
;
;The CAL7 bit determines the range of operation for the oscillator. Setting this bit to 0 gives the
;lowest frequency range, setting this bit to 1 gives the highest frequency range. The two frequency
;ranges are overlapping, in other words a setting of OSCCAL = 0x7F gives a higher frequency than
;OSCCAL = 0x80.
;The CAL6..0 bits are used to tune the frequency within the selected range. A setting of 0x00
;gives the lowest frequency in that range, and a setting of 0x7F gives the highest frequency in the
;range.
;
;Extended Fuse Byte for mega48
;
;Byte Bit No Description Default Value
;– 7 – 1
;– 6 – 1
;– 5 – 1
;– 4 – 1
;– 3 – 1
;– 2 – 1
;– 1 – 1
;SELFPRGEN 0 Self Programming Enable 1 (unprogrammed)
;
;----------------------------------------------------------------------------------------
;锁定位字节:
;
;锁定位字节 位号 默认值 设定值 描述
;
; 7 1 (未编程) 1
; 6 1 (未编程) 1
; 5 1 (未编程) 1
; 4 1 (未编程) 1
; 3 1 (未编程) 1
; 2 1 (未编程) 1
;LB2 1 1 (未编程) 1 锁定位
;LB1 0 1 (未编程) 1 锁定位
;
;锁定位保护模式:
;
;存储器锁定位
;
; LB 模式:
; LB2 LB1 保护类型
; 1 1 没有使能存储器保护特性
; 1 0 在并行和串行编程模式中Flash 和EEPROM 的进一步编
; 程被禁止,熔丝位被锁定。(1)
; 0 0 在并行和串行编程模式中Flash 和EEPROM的进一步编程
; 及验证被禁止,锁定位和熔丝位被锁定(1)
;----------------------------------------------------------------------------------------
;寄存器使用分配:
;
;R1+R0为专用寄存器
; R0
; R1
;
;MUL Rd, Rr 无符号数乘法 R1:R0 ← Rd x Rr Z,C 2
;MULS Rd, Rr 有符号数乘法 R1:R0 ← Rd x Rr Z,C 2
;MULSU Rd, Rr 有符号数与无符号数乘法 R1:R0 ← Rd x Rr Z,C 2
;FMUL Rd, Rr 无符号小数乘法 R1:R0 ← (Rd x Rr) << 1 Z,C 2
;FMULS Rd, Rr 有符号小数乘法 R1:R0 ← (Rd x Rr) << 1 Z,C 2
;FMULSU Rd, Rr 有符号小数与无符号小数乘法 R1:R0 ← (Rd x Rr) << 1 Z,C 2
;LPM 加载程序空间的数据 R0 ← (Z) 无3
;SPM 保存程序空间的数据 (Z) ← R1:R0 无-
;
;专用寄存器:
; R2=
; R3=
; R4=
; R5=
; R6=
; R7=
; R8=
; R9=
; R10=
; R11=
;通用寄存器,中断中使用需要保护:
; R12
; R13
; R14
; R15
;专用状态寄存器:
; R16=
; R17=
; R18=
; R19=
; R20=
; R21=
;通用工作寄存器,中断中使用需要保护:
; R22
; R23
;支持16位操作:
; R24
; R25
;
;X,Y,Z寻址专用寄存器
;X
; R26(XL)=XL
; R27(XH)=XH
;
;LD Rd, X 加载间接寻址数据Rd ← (X) 无2
;LD Rd, X+ 加载间接寻址数据,然后地址加一Rd ← (X), X ← X + 1 无2
;LD Rd, - X 地址减一后加载间接寻址数据X ← X - 1, Rd ← (X) 无2
;
;ST X, Rr 以间接寻址方式存储数据(X) ← Rr 无2
;ST X+, Rr 以间接寻址方式存储数据,然后地址加一(X) ← Rr, X ← X + 1 无2
;ST - X, Rr 地址减一后以间接寻址方式存储数据X ← X - 1, (X) ← Rr 无2
;
;Y
; R28(YH)
; R29(YH)
;LD Rd, Y 加载间接寻址数据Rd ← (Y) 无2
;LD Rd, Y+ 加载间接寻址数据,然后地址加一Rd ← (Y), Y ← Y + 1 无2
;LD Rd, - Y 地址减一后加载间接寻址数据Y ← Y - 1, Rd ← (Y) 无2
;LDD Rd,Y+q 加载带偏移量的间接寻址数据Rd ← (Y + q) 无2
;
;ST Y, Rr 加载间接寻址数据(Y) ← Rr 无2
;ST Y+, Rr 加载间接寻址数据,然后地址加一(Y) ← Rr, Y ← Y + 1 无2
;ST - Y, Rr 地址减一后加载间接寻址数据Y ← Y - 1, (Y) ← Rr 无2
;STD Y+q,Rr 加载带偏移量的间接寻址数据(Y + q) ← Rr 无2
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -