I've begun fiddling with mikrobasic for dsPIC and I've encountered a problem with interrupts.
For now I have 3 sources of interrupt but only two of them work, the flag bit for the third gets set but it won't jump to the interrupt procedure.
Here is my setup part of the program :
Code: Select all
sr = 0
corcon.ipl3 = 0
intcon1 = 0
intcon2 = 0
t1con = 32784
pr1 = 50000
iec0.t1ie = 1
t2con = 32768
pr2 = 65535
ic1con = 131
iec0.ic1ie = 1
ipc0 = 20592
SPI1_Init_Advanced(_SPI_MASTER, _SPI_16_BIT, _SPI_PRESCALE_SEC_2, _SPI_PRESCALE_PRI_16, _SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_low, _SPI_idle_2_active)
ipc2 = 256
iec0.spi1ie = 1
Code: Select all
implements
sub procedure capture org 0x000016
captura = ic1buf
IFS0.IC1IF = 0
portd.11 = not portd.11
end sub
sub procedure spi_ready iv IVT_ADDR_spi1INTERRUPT ics ICS_auto
select case chipselectpointer
case 0
csu1 = 1
csu2 = 0
tensiune1raw = spi1buf
ifs0.spi1if = 0
chipselectpointer = 1
case 1
csu2 = 1
csi1 = 0
tensiune2raw = spi1buf
ifs0.spi1if = 0
chipselectpointer = 2
case 2
csi1 = 1
csi2 = 0
curent1raw = spi1buf
ifs0.spi1if = 0
chipselectpointer = 3
case 3
csi2 = 1
csu1 = 0
curent2raw = spi1buf
ifs0.spi1if = 0
chipselectpointer = 0
convcomplet = 1
end select
if freecomm = 1 then
freecomm = 0
end if
end sub
sub procedure timer1tick iv ivt_addr_t1interrupt ics ics_auto
spi1buf = 0
ifs0.t1if = 0
portd.10 = not portd.10
end sub
The interrupt for the SPI and timer1 works but the one for capture1 doesn't.
I'm planning to add three more sources of interrupt but I don't know if they will work.
The uC is PIC24FJ128GA006 clocked at 32MHz.
Thanks in advance.