plz help using interrupt

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

plz help using interrupt

Jump to solution
1,902 Views
pallav
Contributor I
hi,
i want to use interrupt on Serial recieive(ESCI) i am using QB8 4.9152Mhz crystal
 
plz guide where and how to write the interrupt routine and what r thr various setting or any line i have to write to enable and use interrupt
 
in interupt(RX of ESCI) i want to say tx some byte.
 
 
#include <hidef.h> /* for EnableInterrupts macro */
#include <MC68HC908QB4.h> /* include peripheral declarations */

//macro defination for PORTB out
#define setbit(A,B) A|=(1<<B)
#define clrbit(A,B) A&=~(1<<B)
 
 

void uart_init(void)
{
setbit(DDRB,5);  //TX as output
clrbit(DDRB,4);  //RX as input
SCC1=0x40;
SCC2=0x0c;
SCC3=0x00;
SCBR=0x00;
SCPSC=0xE0;
}

void uart_sendbyte(unsigned char byte)
{
while(!SCS1_SCTE);
while(!SCS1_TC);
SCDR=byte;
while(!SCS1_TC);
}

unsigned char uart_rxbyte(void)
{
unsigned char byte;
while(!SCS1_SCRF);
byte=SCDR;
return byte;
}
 
void delay(unsigned int cycles)
{
while(cycles) cycles--;
}

void adc_init()
 {
  ADCLK = 0x24;
  ADSCR = 0x1F; 
 }
 
unsigned int  adc(unsigned char channel)
 {
   unsigned int adc_value;
   ADSCR |= channel;
   delay(100);
   while(!ADSCR_COCO);
   adc_value=(ADRH<<8);
   adc_value=adc_value+ADRL;
   return adc_value;
 }
 

 
void main(void)
{
   
  CONFIG1=0x01;//disable COP
  delay(1000);
  OSCSC=0xC4;
  delay(100);
  OSCSC |=0x02;
 
  //PTB0=analog input
  //PTB1=Fault digittal input
  //PTB4=RX RS232 INPUT
  //PTB5=TX RS232 OUTPUT
 
  DDRB = 0x00;//All INPUT INITIALLY
  uart_init();
 adc_init();
 
  while(1)
    {
    uart_sendbyte(0xAA);
    delay(500);
    }
 
 
}
 
 
please guide me with some example code
 
thanks and regards
Pallav Aggarwal
Labels (1)
Tags (1)
0 Kudos
1 Solution
373 Views
BlackNight
NXP Employee
NXP Employee
Hello,
Just giving some documentation hints:
I suggest that you first have a look into the compiler manual (in the Help\pdf subfolder). There is information about how to tell the compiler to generate code for interrupt service routines. You can search for #pragma TRAP_PROC or how to use the 'interrupt' keyword.

If you are using the TRAP_PROC way or interrupt without a vector number, you need to tell the linker where to allocate the vectors. See the linker manual and and see the things about 'VECTOR'.

Erich

View solution in original post

0 Kudos
1 Reply
374 Views
BlackNight
NXP Employee
NXP Employee
Hello,
Just giving some documentation hints:
I suggest that you first have a look into the compiler manual (in the Help\pdf subfolder). There is information about how to tell the compiler to generate code for interrupt service routines. You can search for #pragma TRAP_PROC or how to use the 'interrupt' keyword.

If you are using the TRAP_PROC way or interrupt without a vector number, you need to tell the linker where to allocate the vectors. See the linker manual and and see the things about 'VECTOR'.

Erich
0 Kudos