Загромождать проход не хотелось. Думаю, надо копать версию АСМа.
.equ __33FJ12MC201,1
#include "p33FJ12MC201.inc"
.list
.global __reset
.global __U1TXInterrupt
.global __T1Interrupt
.section .xbss
ADC_buffer: .space 36*2
.section .ybss
corellation_pattern: .space 36*2
.section .text
__reset:
mov #__SP_init,w15
mov #__SPLIM_init,w0
mov w0,SPLIM
nop
clr PSVPAG
mov #40,w0
mov w0,PLLFBD
clr CLKDIV
rcall init_ports
rcall timer_init
;mov #(0xffff&(1<<DISSDO|1<<MSTEN|1<<MODE16|1<<PPRE1|1<<PPRE0|1<<SPRE2|1<<SPRE1|1<<SPRE0)),w0
mov #0b0000110000111011,w0
mov w0,SPI1CON1
clr SPI1CON2
;bset SPI1CON2,#15
;bset SPI1STAT,#SPIEN
bset SPI1STAT,#0x000f
forever:
;btss IFS0,#3
btg LATB,#9
goto forever
;mov #0x5555,w0
;bclr LATB,#15
;mov w0,SPI1BUF
;repeat #32
;nop
;bset LATB,#15
;bclr IFS0,#3
;goto forever
;wait_while_full:
;btss SPI1STAT,#1 ;#SPITBF
;goto wait_while_full
mov #0x0040,w0
repeat w0
nop
nop
goto forever
timer_init:
bclr IFS0,#3 ;T1 flag clear
bset IEC0,#3 ;T1 interrupt enable
mov #0b0001000000000000,w0 ;T1 priority lowest
mov w0,IPC0
clr TMR1
mov #0xa0,w0
mov w0,PR1
clr T1CON
bset T1CON,#15 ;set on
return
init_ports:
mov #0b0100110011101101,w0
mov w0,TRISB
nop
mov #0b1000000000000010,w0 ;TXD=1,DACCS=1,DIRECTION=0(rx)
mov w0,LATB
nop
mov #0xffff,w0
mov w0,AD1PCFGL
mov #0x1f00,w0 ;map UART RXD to RP0 (portB0)
mov w0,RPINR18
mov #0x1f0e,w0 ;map SPI MISO to RP14 (portB14)
mov w0,RPINR20
;mov #0x0300,w0 ;map UART TXD to RP1 (portB1)
;mov w0,RPOR0
mov #0x0800,w0 ;map SPI SCK to RP13 (portB13)
mov w0,RPOR6
;mov #0x0900,w0
;mov w0,RPOR7
return
__T1Interrupt:
bclr IFS0,#3 ;T1 flag clear
mov #0x5555,w0
bclr LATB,#15
mov w0,SPI1BUF
repeat #32
nop
bset LATB,#15
retfie
.end