Multiple Interrupt sources

General discussion on mikroBasic PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
serge87
Posts: 45
Joined: 12 Sep 2012 17:55

Multiple Interrupt sources

#1 Post by serge87 » 12 Sep 2012 18:22

Hello.
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
And my interrupt part:

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.
Just tell me....

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: Multiple Interrupt sources

#2 Post by janko.kaljevic » 13 Sep 2012 09:37

Hello,

There are no issues with interrupt handling, and I was able to enter IC1 ISR in ICD, without problems.
I only added TRISD initialization to your code and everything was OK.

Code: Select all

  TRISD = 0            ' Initialize PORTD as output
  TRISD8_bit = 1     ' Set IC1 as input
I tested this on PIC24FJ64GA010 controller.

Best regards.

serge87
Posts: 45
Joined: 12 Sep 2012 17:55

Re: Multiple Interrupt sources

#3 Post by serge87 » 13 Sep 2012 18:11

Thanks for the quick reply.
I have the circuit in simulation with Proteus and it seems that the simulation is to blame.
I will try to put it on the bread board.
Just tell me....

Post Reply

Return to “mikroBasic PRO for dsPIC30/33 and PIC24 General”