All pastes #390907 Raw Edit

Something

public text v1 · immutable
·published 2007-03-11 19:24 UTC
rendered paste body
#include <p18cxxx.h>
#include <timers.h>
#include <usart.h>
#include <pwm.h>

void rx_handler (void);

#define BUF_SIZE 25

#pragma code rx_interrupt = 0x8
void rx_int (void)
{
  _asm goto rx_handler _endasm
}
#pragma code

#pragma interrupt rx_handler
void rx_handler (void)
{
  unsigned char c;

  c = ReadUSART();

  if ( c == 's' )
  {
	PORTB=0x00;
  }
  else
  if ( c == 'x' )
  {
	PORTB=0xff;
  }



  /* Clear the interrupt flag */
  PIR1bits.RCIF = 0;
}

void main (void)
{

  TRISB = 0;

  OpenTimer2(TIMER_INT_OFF & T2_PS_1_1 & T2_POST_1_8);

  OpenPWM1(0xff);
  OpenPWM2(0xff);

  OpenUSART (USART_TX_INT_OFF &
             USART_RX_INT_ON &
             USART_ASYNCH_MODE &
             USART_EIGHT_BIT &
             USART_CONT_RX &
             USART_BRGH_HIGH, 103);


  /* Enable interrupt priority */
  RCONbits.IPEN = 1;

  /* Make receive interrupt high priority */
  IPR1bits.RCIP = 1;

  /* Enable all high priority interrupts */
  INTCONbits.GIEH = 1;

  /* Loop forever */
  while (1)
    ;
}