Serial Interrupt with the MC9S12NE64

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Serial Interrupt with the MC9S12NE64

4,049 次查看
Carlos20
Contributor I
Hi Everybody,
 
I´m having a terrible nightmare when programing the serial with interrupt. Here is the code. I´ll be very gratefull.
 
#include <hidef.h>      /* common defines and macros */
#include <MC9S12NE64.h>     /* derivative information */
unsigned char c;
unsigned char d, aux;
#pragma LINK_INFO DERIVATIVE "1"
void main(void) {
 SCI0BDH = 0x00;
 SCI0BDL = 0x28;
 SCI0CR1 = 0x00;
 SCI0CR2 = 0x2C;
 d=1;
 EnableInterrupts;
 while(1){
    if (d){
       aux = SCI0SR1;
       SCI0DRL = 'f';
       while((SCI0SR1 & 0x80) == 0);
       d=0;
  }
 }
}
 
#pragma CODE_SEG NON_BANKED
interrupt 20 void trataRecepcao(void) {
   aux = SCI0SR1;
   c = SCI0DRL;
   d = 1;
   aux = SCI0SR1;
   SCI0DRL = 'f';
   while((SCI0SR1 & 0x80) == 0);
}
标签 (1)
0 项奖励
3 回复数

461 次查看
Carlos20
Contributor I

Hi,

I would like to thanks the help. Realy, I´m using a demo board and this is the real problem. When i change the serial port SCI0 to SCI1 the software begin to work. This help a lot!

Thanks friends

Carlos

0 项奖励

461 次查看
EMontanez
NXP Employee
NXP Employee
Carlos,
What Mark said is correct. The SCI port would be taken over by the serial monitor program if you are using it on the DEMO board. If not, I attached a project of some SCI code that uses interrupts. The code is project is in CodeWarrior for HCS12 V3.1 and is written for the MC9S12C32. Anyways, the SCI modules should be the same.
Hope you figure out what is wrong.
 
This code is just a crude example and is not intended for production use.
 
Message Edited by t.dowe on 2009-10-20 11:03 PM
0 项奖励

461 次查看
mjbcswitzerland
Specialist V

Hallo Carlos

Are you using the DEMO board with the serial monitor program?
If this is the case you can not use interrupts on serial 0 since they are handled by the serial monitor code. The only way around this would be to delete the serial monitor code and work with a BDM instead.
You can still use serial port 1 though - look at the circuit diagram of the board and you will see that the RS232 level shifter has spare inputs and outputs which can be wired up. Then add a second DSUB connector by drilling a hole in the plastic case.

If this is not your problem, please state what is not working correctly - is the interrupt never arriving or getting stuck in a loop, etc.....

Regards

Mark Butcher
www.mjbc.ch

PS. The uTasker [operating system and TCP/IP stack incl. all drivers, a powerful demo project and a real time simulator for the NE64] is free for educational and hobby use, including free emal support. Send me a mail if you are interested in using it - see live demo at http://212.254.22.36 (user ADMIN passsword AL6000S) and see the device via web cam at http://212.254.22.36:8080 - control LEDs from the I/O web page. Other demos on main web page including Internet enabled BDM for the NE64.

0 项奖励