I thought that I could puzzle this one out myself, but I’m having trouble determining how to access the CS_SID_FILTER_CHANNELS register directly. At this point I’ve been experimenting for about an hour (and I quickly perused the forums and wiki) but haven’t figured this one out yet. And yes, I’m planning on documenting this modification in the wiki! ;D
What I’m attempting to do is have a single button that cycles through the Filter Channels [123] and the external input. Cycling through the first three channels is the default behaviour, and I have my button mapped correctly so that’s working. I can even figure out how to also set toggle the external input bit, that’s not so bad either. The problem I’m having is trying to determine when the three filter channel bits are all set to 1, and then toggle the external bit.
I assumed that (due to the cs_menu_led.inc) the relevant bits should be ANDLW’d with 0x0E first (ie, 0000123E), then I’m using the SUBLW to subtract for comparison. You can see where I’m trying to access the bits below, but I’m a bit confused how to get at the register directly without going through the whole menu structure. Ideally I’m planning on bypassing the menu setup entirely (should be easy once I’ve got the register address / map figured out). The following code is taken from my cs_menu_buttons.inc:
[pre]CS_MENU_BUTTON_Fil_Sel
;; do nothing if button has been depressed
IFSET MIOS_PARAMETER2, 0, return
;; check if the Filter setting is maxed out yet
call CS_MENU_MS_GetSIDBase
movlw 0x80
andwf FSR0L, F
movlw CS_SID_FILTER_CHANNELS
movf PLUSW0, W ; is that the right way to read the register?
andlw 0x0E ; mask the CS_SID_FILTER_CHANNELS register
sublw 0x0E ; subtract for comparison
btfss STATUS, Z ; if zero bit is set, skip next line
goto CS_MENU_BUTTON_Fil_Sel_2
;; obviously the Filter setting is maxed out, so first
;; we want to toggle the EXT filter setting
movlw 0x05 ; cursor pos
movwf MIOS_PARAMETER1
movlw 0x00 ; page offset (maybe?)
movwf MIOS_PARAMETER2
movlw CS_MENU_FIL ; menu structure
call CS_MENU_ButtonToggle ; we’re just turning EXT on or off
; and we’re using a call because we
; want to return back here and then inc the filter
CS_MENU_BUTTON_Fil_Sel_2
;; else increment Filter setting
movlw 0x00 ; cursor pos
movwf MIOS_PARAMETER1
movlw 0x00 ; page offset
movwf MIOS_PARAMETER2
movlw CS_MENU_FIL ; menu structure
goto CS_MENU_ButtonInc
[/pre]
I don’t need a full solution here for my plan, just a way to load up the CS_SID_FILTER_CHANNELS into W. I can take it from there… ![]()