ARM Assembly for development board

I am currently messing around with the LPC 2378, to which an application board is attached. There are several components on the fan, 2 of which are a fan and a heater.

If bits 6 and 7 of port 4 are connected to the fan (motor controller), the following code will turn on the fan:

  FanOn
  STMFD r13!,{r0,r5,r14}      ; Push r0, r5 and LR
  LDR R5, =FIO4PIN            ; Address of FIO4PIN
  LDR r0, [r5]                ; Read current Port4
  ORR r0, r0, #0x80
  STR r0, [r5]                ; Output
  LDMFD r13!,{r0,r5,r14}      ; Pop r0, r5 and LR
  mov pc, r14                 ; Put link register back into PC

How can I rewrite this block of code to turn on the heater connected to bit 5 of port 4 (setting bits to 1 will turn it on, setting it to 0 will turn it off).

Edit after answering the question:

;==============================================================================
; Turn Heater On
;==============================================================================
heaterOn
  STMFD r13!,{r0,r5,r14}      ; Push r0, r5 and LR
  LDR R5, =FIO4PIN            ; Address of FIO4PIN
  LDR r0, [r5]                ; Read current Port4
  ORR r0, r0, #0x20
  STR r0, [r5]                ; Output
  LDMFD r13!,{r0,r5,r14}      ; Pop r0, r5 and LR
  mov pc, r14                 ; Put link register back into PC     
;==============================================================================
; Turn The Heater Off
;==============================================================================        
heaterOff
  STMFD r13!,{r0,r5,r14}      ; Push r0, r5 and LR
  LDR R5, =FIO4PIN            ; Address of FIO4PIN
  LDR r0, [r5]                ; Read current Port4
  AND r0, r0, #0xDF
  STR r0, [r5]                ; Output
  LDMFD r13!,{r0,r5,r14}      ; Pop r0, r5 and LR
  mov pc, r14                 ; Put link register back into PC   
+3
source share
2 answers

As far as I understand the code, the fan is connected only to bit 7 (if the bits are numbered from 0).

The following line is responsible for turning on the fan bit:

ORR r0, r0, #0x80

, 1 , 1. 0x80, 1000 0000 , 7.

, , 5 7 ( ), . 0010 0000 , 0x20 hexa, :

ORR r0, r0, #0x20

, - , , 5, , 1 , 5. BIC, :

BIC r0, r0, 0xDF

, , , , , . - call FanOn. , , , , , . .

, , , , / , . FanOff, HeaterOn...

, , .

+1

ORR , #0x80 ( 7). , AND (, 7, # 0x7F). 5 #0x20 #0xDF.

+1

All Articles