Example #1
0
/* Interrupt Service Routine */
void user_isr( void )
{
	/*T2IF = IFS0 8
	T2IE = IEC0 8
	T2IP = IPC2 26-28
	T2IS = IPC2 24/25
	*/
	//if interrupt clear T2IF and timer counter
	if(IFS(0) & 0x100){
	IFSCLR(0) = 0x100;
	TMR2 = 0;
	if(timeoutcount < 9){
		timeoutcount++;
	}else{
		//print on screen once a second
		timeoutcount = 0;
		time2string(textstring, mytime);
		display_string(3, textstring);
		display_update();
		tick(&mytime);
		//*portE += 1;
		//display_image(96, icon);
	}
}

	if(IFS(0) & 0x8000){
		IFSCLR(0) = 0x8000;
		*portE += 1;
	}
}
Example #2
0
void user_isr (void) {
  clrBuf = SPI2BUF;

  /* ignore CANs and clear clrBuf when switching mode */
  if (receiving && switch_mode) {
    if (clrBuf == CAN)
      clrBuf == EOT;
    else
      switch_mode = 0x00;
  }

  /* receive mode and receive cancel: switch mode to idle mode */
  if (receiving && !switch_mode && clrBuf == CAN) {
    switch_mode = 0x01;
    receiving = 0x00;
    idling = 0x01;
  }

  /* normal receiving, changes LED rate*/
  if (receiving && !switch_mode) {
    if (clrBuf != 1 && clrBuf != 4) { // controls for illegal values
      clrBuf = 1;
    }
    LED_rate = (LED_NORMAL/clrBuf);
  }

  /* discards CANs when switching mode from idling to receiving */
  if (idling && switch_mode) {
    if (clrBuf == CAN)
      clrBuf = EOT;
    else
      switch_mode = 0x00;
  }

  /* receive ACK in idle mode switches to active mode (sending string) */
  if (idling && !switch_mode && clrBuf == ACK) {
    idling = 0x00;
    active = 0x01;
  }

  /* switch from idle mode to receive mode */
  if (idling && !switch_mode && clrBuf == CAN) {
    idling = 0x00;
    receiving = 0x01;
    switch_mode = 0x01;
  }

  IFSCLR(1) = (1<<7);
}
/* Interrupt Service Routine */
void user_isr( void ) {


  timeoutcount++;

  if (timeoutcount == 10){
    time2string( textstring, mytime );
    display_string( 3, textstring );
    display_update();
    tick( &mytime );
    timeoutcount = 0;
  }
  // clearing flag
  IFSCLR(0) = 0x100;
  
  }
Example #4
0
/* Interrupt Service Routine 
user_isr is called from file vectors.S which is where the interrupt service routine
is installed. Before user_isr is called in vectors.S the state of all registers
is saved because the execution can be anywhere in the program when the interrupt
is called. Only some registers are saved because the other registers belong to
variables which are defined as such registers which should be saved sepparately by
the program on for example on a stack.*/
user_isr( void ) 	// Acknowledge interrupts from Timer 2
{	
	// Time-out event-flag will be checked 10 times/second. This is because
	// Timer 2 interrupt-flag will be reached each 100 ms and create an interrupt call.
	// Time-out event-flag will be set to 1 when this function is called.
	// If time-out event-flag isn't cleared user_isr will execute constantly.
	IFSCLR(0) = 0x0100;		// Clear the Timer 2 interrupt flag
	//T2IE timer2 interupt enable
	if (timeoutcount == 10) {
		timeoutcount = 1;
	  	time2string( textstring, mytime );
  		display_string( 3, textstring );
  		display_update();
  		tick( &mytime );
	} else {
		timeoutcount++;
	}
return;
}