I'm posting a follow-up to this in case it may help someone else. Though I'm really not happy with this device (the clock jitter in INTOSC mode is too severe for my tastes) here's what I've found out. It appears that BANKSEL does not work on this device. Not sure why; I've reported it to the guys at meLabs and I'm sure they'll get to the bottom of it. In the meantime, assembly to the rescue. If you are not aware of it, there are two things I got from this exercise:
1.) A friend had to remind me that going back to the early days of the '54, there wasn't a TRIS register; there was a TRIS command. This device, being part of the 12-bit core series, uses the TRIS command. So, you load "W" with the value you want TRIS to be, and then use the TRIS command to set the I/O. No big deal, as long as you're aware of it. You can see it in the code.
2.) BANKSEL doesn't work (nor does BSR). There is in fact, yet again, a command for this: MOVLB - move literal to BSR.
Once past those two things, things started looking up (the attached code compiles and runs fine). One thing to keep in mind, generally speaking with any of the devices that have alternate functions on a pin (in other words, all PIC's); set these functions prior to setting TRIS, otherwise these functions will trample on TRIS. Or bit select them, however you like to code. I'm spoiled by the PIC16F1xxx series, and if it wasn't for the fact that these "smaller" devices are so cheap, would use them for everything.
Code:
'****************************************************************
'* Name : LED_003.BAS *
'****************************************************************
;#CONFIG
; __config _FOSC_INTRC_CLKOUT &_WDTE_OFF &_CP_OFF &_MCLRE_ON &_IOSCFS_8MHz &_CPSW_OFF &_BOREN_ON &_DRTEN_OFF
;#ENDCONFIG
DEFINE OSC 8
;ALIASES
LED VAR PORTC.0 ; OUTPUT - DIGITAL
;PORT CONTROL REGISTERS
asm
MOVLB b'00000000' ; SELECT BANK 0
MOVLW b'00000000'
MOVWF ADCON0
MOVLW b'00000000'
MOVWF INTCON0
MOVLW b'00000000'
MOVWF INTCON1
MOVLB b'00000001' ; SELECT BANK 1
MOVLW b'00000000'
MOVWF CM1CON0
MOVLW b'00000000'
MOVWF CM2CON0
MOVLW b'00000000'
MOVWF VRCON
MOVLB b'00000010' ; SELECT BANK 2
MOVLW b'00000000'
MOVWF ADCON0
MOVLW b'00000000'
MOVWF INTCON0
MOVLW b'00000000'
MOVWF INTCON1
MOVLB b'00000011' ; SELECT BANK 3
MOVLW b'00000011'
MOVWF OPACON
MOVLW b'11001101'
MOVWF ANSEL
MOVLB b'00000000'
MOVLW b'00010101' ; LOAD W
TRIS 06h ; LOAD TRIS PORTA
MOVLW b'00010000' ; TRIS PORTB
TRIS 07h
MOVLW b'11000000'
TRIS 08h
endasm
low led
MAIN:
HIGH led
pause 250
low led
pause 250
goto main
end
Bookmarks