Hello
I use codewarrior (with C language), a evaluationboard with a MC9S12DP512 and a P&E bdm mulitlink
I 've make a program to blinking a LED, it's OK
I've runnig this program with the PLL (48MHz), it's OK
I''ve put in the main the code to send a caracter to the SCI port, it's OK
BUT
I want to use the SCI port with interrupt, typically, I want to blinking the LED but if a 'A' caractere arrive on the SCI port I want to stop the blinking.
I don't arrive to use the interrupt.
Can someone help me to use the interrupt??
for the SCI.c
#include "datatypes.h"
//#include "hcs12dp256.h"
#include <mc9s12dp512.h> /* derivative information */
#include "s12_sci.h"
//-- Code ---------------------------------------------------------------------
void initSCI0(UINT16 bauddiv) {
/*
before install the PLL with a 16 MHz quartz
SCI0BD = bauddiv & 0x00A3; // baudrate divider has 13 bits
*/
// I have running the PLL at 48MHz so the baud rate is different
SCI0BD = bauddiv & 0x1fff; // baudrate divider has 13 bits
SCI0CR1 = 0; // mode = 8N1
SCI0CR2 = BM_TE+BM_RE; // Transmitter + Receiver enable
}
//-----------------------------------------------------------------------------
UINT8 getSCI0(void) {
while((SCI0SR1 & BM_RDRF) == 0) ;
return SCI0DRL;
}
//-----------------------------------------------------------------------------
void putSCI0(UINT8 c) {
while((SCI0SR1 & BM_TDRE) == 0) ;
SCI0DRL = c;
}
*****************************************************************************
*****************************************************************************
for the main:
#include <hidef.h> /* common defines and macros */
#include <mc9s12dp512.h> /* derivative information */
#include "s12_crg.h"
#include "s12_sci.h"
#pragma LINK_INFO DERIVATIVE "mc9s12dp512"
UINT8 entree_SCI;
// some simple delay routines
//
void delay1(void) {
volatile unsigned n = 36000u;
do {
n--;
} while(n);
}
void delay2(void) {
volatile unsigned n, m;
m = 3;
do {
n = 0;
do {
n--;
} while(n);
m--;
} while(m);
}
//-----------------------------------------------------------------------------
// program entry is here:
//
void main(void) {
unsigned char k,m;
EnableInterrupts;
initPLL();
// initSCI0(1);
SCI0BD = 0x0027;// baudrate divider has 13 bits
SCI0CR1 = 0; // mode = 8N1
SCI0CR2 = BM_TE+BM_RE; // Transmitter + Receiver enable
PORTB = 0xff;
DDRB = 0xff;
PTP = 0;
DDRP = 0x03;
m = 0;
while(1) {
k = 0x80;
do {
PORTB &= ~k; // LED on
delay1();
PORTB |= k; // LED off
k >>= 1;
} while(k);
if(++m==4) m = 0;
PTP = m;
k = 0x01;
do {
PORTB &= ~k; // LED on
delay1();
PORTB |= k; // LED off
k <<= 1;
} while(k);
delay2();
// entree_SCI= getSCI0();
putSCI0('a');
}
}
Thanks for your Help!!!!
I'm realy desapointed
Escuse me for spelling mistake, I'm french.