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 support@ccsinfo.com

18f4550 AND TIMERS

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



Joined: 12 Feb 2008
Posts: 14

View user's profile Send private message

18f4550 AND TIMERS
PostPosted: Mon Sep 15, 2008 10:08 am     Reply with quote

Hello everybody!

I need help once more, I have a external interrupt, (INT_EXT2). I want to do the following: The PIC must wake from minute to minute and do the interrupt code, but I don´t know how to do it. Wake every minute and do the code in interrupt.
In my code i have this:
Code:
#include <18F4550.h>
#DEVICE ADC=8
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
#use delay(clock=48000000)
#include <usb_cdc.h>                                                            //USB CALL
/********************************** LCD ***************************************/
#define RS_LCD  PIN_D1
#define CSB_LCD  PIN_D0

#bit IDLEN=0xFD3.7 //SLEEP MODE


unsigned char valorADC;
unsigned char RB2;
unsigned char RB3;     
unsigned char MSB;
unsigned char controlo;
unsigned char string[18];
unsigned char tempoSleep;


unsigned char modo_Vref; //VREF a guardar na memória EEPROM da PIC
Unsigned char canal_1,canal_2,canal_3,canal_4,canal_5,canal_6,canal_7,canal_8; //Canais a amostrar


unsigned char canal1,canal2,canal3,canal4,canal5,canal6,canal7,canal8;
unsigned char auxcanal1,auxcanal2,auxcanal3,auxcanal4,auxcanal5,auxcanal6,auxcanal7,auxcanal8; //variáveis auxiliares para guardar tempos amostragem

#INT_EXT2 // External interrupt #2
 
   void temp_amostras()
   {
      if(canal1==0)
      {
         auxcanal1 = canal1;
         //guarda na EEPROM os dados
      }
      if(canal2==0)
      {
         auxcanal2 = canal2;
         //guarda na EEPROM os dados
      }
      if(canal3==0)
      {
         auxcanal3 = canal3;
      }
      if(canal4==0)
      {
      auxcanal4 = canal4;
      }
      if(canal5==0)
      {
         auxcanal5 = canal5;
      }
      if(canal6==0)
      {
         auxcanal6 = canal6;
      }
      if(canal7==0)
      {
         auxcanal7 = canal7;
      }
      if(canal8==0)
      {
         auxcanal8 = canal8;
      } 
      auxcanal1--;auxcanal2--;auxcanal3--;auxcanal4--;auxcanal5--;auxcanal6--;auxcanal7;auxcanal8--;
         }

...

void main(){
   
   enable_interrupts(INT_EXT2);
   enable_interrupts(GLOBAL);
   ext_int_edge( 2,H_TO_L ); // Nivel lógico da interrupção 
   IDLEN=1;
   
   //*********************EEPROM************************************************
   if(read_eeprom(0x00)==0xFF){
      modo_Vref=5;
   }
   else{
   modo_Vref=read_eeprom (0x00);
   }

   lcd_clear();
   potDigital(modo_Vref);//teste
   setup_adc(ADC_CLOCK_INTERNAL);
   setup_adc_ports(AN0_TO_AN7|VSS_VDD);
   setup_spi(SPI_MASTER|SPI_H_TO_L|SPI_XMIT_L_TO_H|SPI_CLK_DIV_64);
   output_high(CS_ADC); //CS ADC externo a 1
   start_ds1305();
   
   
   lcd_setup();
 
  //----------------------------------MENUS-------------------------------------
   do
   {
   menu_inicial();
   menu_aux();
   if (tempoSleep==1)
      sleep();
   }while(true);

}

PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Sep 15, 2008 3:19 pm     Reply with quote

Quote:
Wake every minute and do the code in interrupt.

Do you have a signal on the INT2 pin of the 18F4550 that has a
rising edge once per minute ? Describe the signal on the INT2 pin.
What is the frequency of this signal ?
madeiras



Joined: 12 Feb 2008
Posts: 14

View user's profile Send private message

PostPosted: Tue Sep 16, 2008 7:14 am     Reply with quote

PCM programmer wrote:
Quote:
Wake every minute and do the code in interrupt.

Do you have a signal on the INT2 pin of the 18F4550 that has a
rising edge once per minute ? Describe the signal on the INT2 pin.
What is the frequency of this signal ?


I want to plug to INT2 PIN an RTC (http://datasheets.maxim-ic.com/en/ds/DS1305.pdf). My RTC has 2 alarms, but i only can define an hour to him wakeup. I want that he give a signal every minute to INT2 PIN, but i don´t know to do it.

I´ve read about timers of PIC. I could use them instead? But I don´t know how to put them given an interrupt every minute.

Tk´s, I'm new on these things, and I'm learning by myself using this!
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