Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Thread Closed: Issue successfully resolved

???
08/06/04 06:45
Read: times


 
#75535 - RE: Memory mapped I/O hassle
Responding to: ???'s previous message
hi,

could you explain your problem more clean, please? As for now I do not see any problem with it. For example:

1) If you have enough bitfield space then just use it as refresh data holder:
CONTROL_REG	DATA	0x20
RELAY_A		BIT	CONTROL_REG.0		; relay control: 0 - on; 1 - off
;...
MOTOR_1		BIT	CONTROL_REG.7		; motor control: 1 - on; 0 - off

; somewhere in program:
	CLR	RELAY_A				; switch relay A on
	SETB	MOTOR_1				; run motor 1
; ...
	CLR	MOTOR_1				; stop motor 1
	SETB	RELAY_A				; switch relay A off

It may annoy to remember which bit level does control which device state. So just write macros. They may be useful as well if due some reason the hardware will be changed - in this case you need edit just some macros:
RELAY_ON	MACRO relay_name
	CLR	relay_name
		ENDM
RELAY_OFF	MACRO relay_name
	SETB	relay_name
		ENDM
MOTOR_ON	MACRO motor_number
	SETB	motor_number
		ENDM
MOTOR_OFF	MACRO motor_number
	CLR	motor_number
		ENDM

; somewhere in program:
	RELAY_ON  RELAY_A
	MOTOR_ON  MOTOR_1	
;...
	MOTOR_OFF MOTOR_1
	RELAY_OFF RELAY_A

2) If you have not enough bitfield space then use that you have - just a data space:
CONTROL_REG	DATA	0x40
; specify bits` positions
RELAY_A		EQU	00000001b		; bit 0 does relay control: 0 - on; 1 - off
;...
MOTOR_1		EQU	10000000b		; bit 7 does motor control: 1 - on; 0 - off

; useful macros:
RELAY_ON	MACRO bit_position
	ANL	CONTROL_REG,#NOT(bit_position)
		ENDM
RELAY_OFF	MACRO bit_position
	ORL	CONTROL_REG,#bit_position
		ENDM
MOTOR_ON	MACRO bit_position
	ORL	CONTROL_REG,#bit_position
		ENDM
MOTOR_OFF	MACRO bit_position
	ANL	CONTROL_REG,#NOT(bit_position)
		ENDM

; somewhere in program:
	RELAY_ON  RELAY_A
	MOTOR_ON  MOTOR_1
;...
	MOTOR_OFF MOTOR_1
	RELAY_OFF RELAY_A

That`s all!

Regards,
Oleg


List of 17 messages in thread
TopicAuthorDate
Memory mapped I/O hassle            01/01/70 00:00      
   RE: Memory mapped I/O hassle            01/01/70 00:00      
      Problem defenition - Erik            01/01/70 00:00      
   RE: Memory mapped I/O hassle            01/01/70 00:00      
      Automatic up I/O update - Russell            01/01/70 00:00      
   RE: Memory mapped I/O hassle            01/01/70 00:00      
      RE: Memory mapped I/O hassle            01/01/70 00:00      
         RE: Memory mapped I/O hassle            01/01/70 00:00      
            RE: Memory mapped I/O hassle            01/01/70 00:00      
               RE: Memory mapped I/O hassle            01/01/70 00:00      
            Syntax - Anders, Rob, Charles            01/01/70 00:00      
               RE: Syntax - Anders, Rob, Charles            01/01/70 00:00      
                  Problem solved - Russell            01/01/70 00:00      
               RE: Syntax - Anders, Rob, Charles            01/01/70 00:00      
                  RE: Syntax - Anders, Rob, Charles            01/01/70 00:00      
   RE: Memory mapped I/O hassle            01/01/70 00:00      
      Thread can close happily            01/01/70 00:00      

Back to Subject List