CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Active low interrupt

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
warren.woolseyiii



Joined: 19 Jul 2013
Posts: 10

View user's profile Send private message

Active low interrupt
PostPosted: Wed Oct 09, 2013 5:44 pm     Reply with quote

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 Smile
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

View user's profile Send private message

PostPosted: Wed Oct 09, 2013 6:18 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Oct 10, 2013 11:16 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Oct 10, 2013 11:17 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Oct 10, 2013 11:26 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Oct 10, 2013 11:57 pm     Reply with quote

Got it, thank you!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group