View previous topic :: View next topic |
Author |
Message |
warren.woolseyiii
Joined: 19 Jul 2013 Posts: 10
|
Active low interrupt |
Posted: Wed Oct 09, 2013 5:44 pm |
|
|
Hi all,
I am using an external ADC that uses an active low pin to signal when the data is ready. I want to know how I can use the external interrupt on my dsPIC to utilize this active low signal for an interrupt.
I am using the dsPIC33FJ64GS606, with an ICD-U64 debugger, and the CCS IDE and compiler v4.134.
Everything is hooked up correctly on the hardware, but my interrupt only sets off when the data ready pin transitions from low to high (the opposite of what I desire).
I am new to programming, so if you have any solutions please post example code, or direct me to a source that I can find some example code
Code: |
#INCLUDE <33FJ64GS606.h> //Library for the dsPIC MPU
#DEVICE ICD=3 //ICD Debugger through PGD3/PGC3 Pins
#INCLUDE <stdlib.h>
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES EC //Crystal Oscillator @ 2.592MHz
#FUSES NOWDT //No Watch Dog Timer
#FUSES NOPUT //No Power Up Timer
#FUSES NOJTAG //JTAG disabled
#FUSES PR_PLL //Primary Oscillator w/ PLL
#USE delay(oscillator=2.592MHz, clock=72.576MHz) //External Crystal Oscillator @ 2.592MHz w/ PLL for 72.576MHz
#USE rs232(baud=9600, xmit=PIN_F5, rcv=PIN_F4)
#DEFINE SCLK PIN_G6
#DEFINE DOUT PIN_G7
#DEFINE DREADY PIN_G9
#INT_EXT2
void ext2_isr() {
int i;
unsigned char* byteArray[31];
for(i=0;i<32;i++) {
shift_right(byteArray, 4, input(DOUT));
}
printf("\r\n%d", byteArray);
}
void main() {
setup_spi2(SPI_MASTER | SPI_CLK_DIV_112);
enable_interrupts(INT_EXT2);
while (1) {
}
} |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Oct 09, 2013 6:18 pm |
|
|
Download the PCD compiler manual. Keep it on your Windows desktop:
http://www.ccsinfo.com/downloads/PCDReferenceManual.pdf
Look in the Interrupts summary section on page 54. It lists useful CCS
interrupt functions. You will find the function you want there. Then go
to the detailed section on that function. |
|
|
warren.woolseyiii
Joined: 19 Jul 2013 Posts: 10
|
|
Posted: Thu Oct 10, 2013 11:16 am |
|
|
I checked the PCD Reference manual that you posted, and I found the function;
setup_low_volt_detect();
However, it seems that the dsPIC33FJ64GS606 does not have a high/low voltage detect module. I looked in the device header file, and the LVD constants defined in the manual are not present.
Does the dsPIC33FJ64GS606 have a high/low voltage detect module?
Also, thank you for your reply! |
|
|
warren.woolseyiii
Joined: 19 Jul 2013 Posts: 10
|
|
Posted: Thu Oct 10, 2013 11:17 am |
|
|
Also, I checked the data sheet for the dsPIC33FJ64GS606 and I did not find a high/low voltage detection module. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Oct 10, 2013 11:26 am |
|
|
You asked this question:
Quote: |
I am using an external ADC that uses an active low pin to signal when the
data is ready. I want to know how I can use the external interrupt on my
dsPIC to utilize this active low signal for an interrupt.
|
This means to me, that your ADC chip puts out a digital signal (a negative
pulse, or a low level) to indicate attention is needed from the micro-
controller. You want to know how to select the edge (positive or negative)
on which to trigger the interrupt.
Right there on page 54 of the PCD manual, it tells you which function to use:
Quote: |
Interrupts
The following functions allow for the control of the interrupt subsystem of the microcontroller. With these functions, interrupts can be enabled, disabled, and cleared. With the preprocessor directives, a default function can be called for any interrupt that does not have an associated ISR, and a global function can replace the compiler generated interrupt dispatcher.
Relevant Functions:
disable_interrupts() - Disables the specified interrupt.
enable_interrupts() - Enables the specified interrupt.
ext_int_edge() - Enables the edge on which the edge interrupt
should trigger. This can be either rising or falling edge.
|
|
|
|
warren.woolseyiii
Joined: 19 Jul 2013 Posts: 10
|
|
Posted: Thu Oct 10, 2013 11:57 pm |
|
|
Got it, thank you! |
|
|
|