so I’ve found 2 methods to do the blinking in ASM:
- timer initialization - I place this to USER_Init (but,you can start or finish timer any time)
Code:
movlw 31250 & 0xff
movwf MIOS_PARAMETER1
movlw 31250 >> 8
movwf MIOS_PARAMETER2
movlw 0x03
call MIOS_TIMER_Init
timer jump to USER_Timer every 25ms from now
- You must write this definition on the top of main.asm
(determine count of skips then blinking routine will be perform)
Code:
#define LX_CLIPS_BLINKING_SPEED 8 ; 6=quickly 8=mediumly 10=slowly
- USER_Timer
-----------
Code:
USER_Timer
; This is for erase speed interval…
movf LX_BL_Clock, W
sublw LX_CLIPS_BLINKING_SPEED
skpnz
clrf LX_BL_Clock
; if LX_BL_Clock = 0 go to LX_PrePlay_BL routine…
movlw 0x01
subwf LX_BL_Clock, W
skpc
rgoto LX_PrePlay_BL
rgoto LX_Timer_End
LX_PrePlay_BL
IFCLR LX_BL_Enable, 0, rgoto LX_Timer_End
IFSET LX_BL_Switch, 0, rgoto LX_LED_PrePlay_On
LX_LED_PrePlay_Off
; >> ------------------ LED Off ------------------
movf LX_Blinking_Button, W
call MIOS_DOUT_PinSet0
bsf LX_BL_Switch, 0
rgoto LX_Timer_End
; << ------------------ LED Off ------------------
LX_LED_PrePlay_On
; >> ------------------ LED On ------------------
movf LX_Blinking_Button, W
call MIOS_DOUT_PinSet1
bcf LX_BL_Switch, 0
; << ------------------ LED On ------------------
LX_Timer_End
incf LX_BL_Clock, F
return
registers
LX_BL_Switch - if bit D0 is 0/1=On/Off LED
LX_BL_Enable - if D0 is 0/1=disable/enable blinking
LX_Blinking_Button - into save number of button
and TKs method
USER_SR_Service_Prepare
LED_FLASH_Handler
;; increment counter
incf DOUT_LED_CTR, F
;; skip next block if LED should not flash
IFCLR DOUT_LED_FLASH_ENABLE, 0, rgoto LED_FLASH_Handler_Skip0
;; skip if DOUT counter < 128 (bit #7 not set), this leads to a
;; flashing frequency of 1 / (128 * update_cycle) = 1 / (128 * 1 mS) = ca. 8 Hz
IFCLR DOUT_LED_CTR, 7, rgoto LED_FLASH_Handler_Skip0
;; get value of LED at DOUT #0
movlw 0x00
call MIOS_DOUT_PinGet
;; result in MIOS_PARAMETER1, invert it
comf MIOS_PARAMETER1, F
;; write back result to DOUT #0
movlw 0x00
call MIOS_DOUT_PinSet
LED_FLASH_Handler_Skip0
;; thats all
return
being completely ignorant of ASM - how do I pass either of the code sets the Pin number of the LED I want to control using the in-line ASM functionality in C?