예제 #1
0
void reset_event()
{
   switch ( restart_cause() )
   {
      case WDT_TIMEOUT:
      {
         printf("@WDT\r\n");
         sprintf(event_str, ",restart cause,WD time-out\r\n");
         record_event();
         recovery();
         break;
      }
      case WDT_FROM_SLEEP:
      {
         printf("@WDS\r\n");
         sprintf(event_str, ",restart cause,WD from sleep\r\n");
         record_event();
         recovery();
         break;
      }      
      case NORMAL_POWER_UP:
      {
         printf("@NPU\r\n");
         sprintf(event_str, ",id#[%Lu],power applied,SD initialized\r\n", nv_serial);
         record_event();
         break;
      }
      case RESET_INSTRUCTION:
      {
         printf("@RST\r\n");
         sprintf(event_str, ",restart cause,reset instruction\r\n");
         record_event();
         break;
      }
      case BROWNOUT_RESTART:
      {
         printf("@BOR\r\n");
         sprintf(event_str, ",restart cause,brown-out\r\n");
         record_event();
         recovery();
         break;
      } 
      case MCLR_FROM_SLEEP:
      {
         printf("@MRS\r\n");
         sprintf(event_str, ",restart cause,MCLR from sleep\r\n");
         record_event();
         recovery();
         break;
      }   
      case MCLR_FROM_RUN:
      {
         printf("@MRR\r\n");
         sprintf(event_str, ",restart cause,MCLR when running\r\n");
         record_event();
         recovery();
         break;
      }        
   }
}
예제 #2
0
파일: main.c 프로젝트: EPSA-Legacy/RISM
void main()
{
	char reponse='a';
	int flag=255;
	int id1=23;	
	int id2=12;

	int value1=15;
	int value2=16;
	int value3=17;
	
	//initialisation du PIC 
	setup_adc(ADC_OFF);  		//on gère toutes les entrées comme étant de type analogique et on mesure les tensions par rapport à une ref 5V


	enable_interrupts(INT_TIMER2);      //configuration des interruptions
	enable_interrupts(INT_AD);
	enable_interrupts(GLOBAL);

	setup_timer_2(T2_DIV_BY_4,250,5);   //setup up timer2 to interrupt every 0,1ms
	can_init();							//initialise le CAN
	can_set_baud();						//obsolète à priori à tester
	restart_wdt();

	#ifdef DEBUG
	   // Mise en évidence d'un problème lié au Watchdog
   	   switch ( restart_cause() )
       {
          case WDT_TIMEOUT:
          {
             printf("\r\nRestarted processor because of watchdog timeout!\r\n");
             break;
          }
          case NORMAL_POWER_UP:
          {
             printf("\r\nNormal power up! PIC initialized \r\n");
             break;
          }
       }
       restart_wdt();
    #endif


	//  BOUCLE DE TRAVAIL
	while(TRUE)
	{
		putc(flag);
		putc(id1);
		putc(value1);
		putc(flag);
		putc(id1);
		putc(value2);
		putc(flag);
		putc(id2);
		putc(value3);
	}
}
예제 #3
0
파일: main.c 프로젝트: EPSA-Legacy/RISM
void main()
{
	//initialisation du PIC
	setup_adc_ports(NO_ANALOGS);        //on gère toutes les entrées comme étant de type numérique

	enable_interrupts(INT_TIMER2);      //configuration des interruptions
	enable_interrupts(GLOBAL);

	setup_timer_2(T2_DIV_BY_4,250,5);   //setup up timer2 to interrupt every 1ms
	can_init();							//initialise le CAN
	restart_wdt();

	#ifdef DEBUG
	   // Mise en évidence d'un problème lié au Watchdog
   	   switch ( restart_cause() )
       {
          case WDT_TIMEOUT:
          {
             printf("\r\nRestarted processor because of watchdog timeout!\r\n");
             break;
          }
          case NORMAL_POWER_UP:
          {
             printf("\r\nNormal power up! PIC initialized \r\n");
             break;
          }
       }
       restart_wdt();
    #endif



	//  BOUCLE DE TRAVAIL
	while(TRUE)
	{
		restart_wdt();
		listenCAN();
	}
}