Brem
Member level 1
eagle pic24f
The ISR in the bootloader and OS are excactly the same and only service TRM0 interrupts. Using BL int for OS shouldn't be a problem... I think.
Loaded the firmware on a 2550 and it enumerates correctly. Program gets read,written and read again. Then MPLAB sends a "06" command which is probably a reset request. The following "03" command to query firmware version does not get a response... Maybe my USB monitor can not monitor through a disconnect/reconnect.
Oh, and I also needed a "GOTO ISR" on the low-priority int vector (0x0018). It wouldn't enumerate without.
This is what I can make of the bootloaders main(), so far...
The ISR in the bootloader and OS are excactly the same and only service TRM0 interrupts. Using BL int for OS shouldn't be a problem... I think.
Loaded the firmware on a 2550 and it enumerates correctly. Program gets read,written and read again. Then MPLAB sends a "06" command which is probably a reset request. The following "03" command to query firmware version does not get a response... Maybe my USB monitor can not monitor through a disconnect/reconnect.
Oh, and I also needed a "GOTO ISR" on the low-priority int vector (0x0018). It wouldn't enumerate without.
This is what I can make of the bootloaders main(), so far...
Code:
0184:main_0_0:
MOVFF FSR2L, POSTINC1
0188 MOVFF FSR1L, FSR2L
018C MOVF POSTINC1, F, ACCESS
018E BCF INTCON2, 0x7, ACCESS
0190 RCALL GetRB7 ;returns (RB7==0?1:0)
0192 MOVWF INDF2, ACCESS
0194 MOVLB 0
0196 MOVF 0xf0, W ;If [0xF0]<>0 goto bootload
0198 BNZ 0x1a8
019A MOVF INDF2, W ;If RB7==0 goto bootload
019C BNZ 0x1a8
019E RCALL TestIfOSAvail_0_5 ;If ==0 goto bootload
01A0 IORLW 0
01A2 BZ 0x1a8
01A4 GOTO 0x2800 ;start OS
01A8:bootload:
CLRF POSTINC1, ACCESS
01AA CALL InitTMR0_2_0, 0
01AE MOVF POSTDEC1, F, ACCESS
01B0 CALL InitIO, 0
01B4 MOVLW 0x14 ;UCFG =
01B6 MOVWF UCFG, ACCESS ;_PUEN|_TRINT|_FS|MODE_PP
01B8 MOVLB 0
01BA CLRF usb_device_state, BANKED
01BC MOVLB 0
01BE CLRF usb_state, BANKED
01C0 MOVLB 0
01C2 CLRF usb_active_cfg, BANKED
01C4:while1:
BTFSS PORTA, 0x4, ACCESS ; If RC4==High
01C6 BRA 0x1cc
01C8 CALL Hela_RA4IsHigh, 0 ;set RB3, loop forever flashing
RC1
01CC CALL USBCheckBusStatus, 0
01D0 CALL USBDriverService_0_1, 0
01D4 IORLW 0
01D6 BZ 0x1ee
01D8 MOVLW 0x8
01DA MOVWF POSTINC1, ACCESS
01DC MOVLW 0x40
01DE MOVWF POSTINC1, ACCESS
01E0 MOVLW 0
01E2 MOVWF POSTINC1, ACCESS
01E4 CALL ProcessIO_4_0, 0
01E8 MOVF POSTDEC1, F, ACCESS
01EA MOVF POSTDEC1, F, ACCESS
01EC MOVF POSTDEC1, F, ACCESS
01EE BRA 0x1c4
01F0 MOVF POSTDEC1, F, ACCESS
01F2 MOVF POSTDEC1, F, ACCESS
01F4 MOVFF INDF1, FSR2L
01F8 RETURN 0