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

Is #INT_COMP broken?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

Is #INT_COMP broken?
PostPosted: Mon May 24, 2010 5:12 pm     Reply with quote

In the recent versions ex v4.106 say using 18F2620 or 18F8720 the interrupt does not to work when volts on F6 cross 3.6v ( f4 is tied to GND)
I did a search on #INT_COMP and if I have it right there maybe an issue.

Code:
#include <18F8720.h>

#fuses HS,NOPROTECT,NOPUT,NOBROWNOUT,NOLVP,NOWDT
//////////////

#device *=16
#device adc=10
#use delay(clock=8MHZ,restart_wdt)

////// ////////////////////////////////////////////////////////////////
/// RS232 interface using hardware
/// this will be interrupt driven using a circular buffer

//#use rs232(STREAM=WPS, baud=9600, xmit=PIN_C6,rcv=PIN_C7,ERRORS)


////// ////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////
//////////////////////////// debugging //////////////////////////////
////////////////////////////////////////////////////////////////////

 #use rs232(debugger) ///// debug printf to monitor/////////////////
 
int8 safe_conditions=TRUE;
int8 compare_reg;
#byte CMCON= 0x0fb4
#INT_COMP
void isr() 
{
compare_reg=CMCON; ////// must read to clear flag
if(c1OUT==1) safe_conditions=TRUE;
else  safe_conditions=FALSE; 
}


void main()
 {
 

 printf("\r\n comparator test...\r\n\n");
   
 output_high(PIN_h1);
   
  setup_comparator( F6_VR_F4_VR);
   
   setup_vref(VREF_HIGH|15); //// 5v vdd this is 3.6v

/// two lines below are uncommented when testing interrupt
  // enable_interrupts(INT_COMP);
 //  enable_interrupts(GLOBAL);


   while(TRUE)
   {
 ///// code below doesn't work when the /* */ pair is removed
   /* 
 
     if(safe_conditions==true)
       {
        output_high(PIN_H1);
       
       } 
      else
      {
      output_low(PIN_H1);
     
      }
      safe_conditions=TRUE;
      */
     ///// code below works but is not interrupt driven
   
      if(c1OUT==1)
        {
        output_high(PIN_H1);
     
        }
       else
       {
       output_low(PIN_H1);
     
       }
       
      delay_ms(500);
   }
 
 }
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon May 24, 2010 8:09 pm     Reply with quote

Quote:
In the recent versions ex v4.106

Can you post an earlier version of the compiler that runs your program
(with interrupts enabled) and is guaranteed to work ? If you can, then
I can compile the program with that version and with vs. 4.106.
Then I can compare the .LST files with ExamDiff and it wll instantly
highlight any differences.
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Tue May 25, 2010 12:31 am     Reply with quote

In the main routine this statement should not be there
Code:
safe_conditions=TRUE;

In the isr
Code:
compare_reg=CMCON; ////// must read to clear flag 

the above statement isn't necessary since flag is cleared by compiler

#INT_COMP is working and never was broken it was my code that was at fault

PCM programmer thanks for the offer of assistance
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