SCI Interrupt issues on S12XDP512

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

SCI Interrupt issues on S12XDP512

1,545件の閲覧回数
AmeyaTipnis
Contributor I

Hi Forum,

 

Problem: SCI transmission using interrupts, but TC / TDRE flags never clear, even after reading the Status register.

 

I am a new Freescale user (experienced Embedded developer), and I am trying to get a feel of the S12X processor, by configuring a simple serial communication with the PC. Before posting I read through the forum for almost the whole day today, some posts were pretty similar to my problem but I did not get an answer. Hence all help will be deeply appreciated.

 

I am using the Softec ZK-S12-B starter kit with a MC9S12XDP512 device and a Softec Indart-one BDM interface. For the moment I have just written code which has a timer interrupt and an SCI interrupt. I am using the SCI0 module to send some characters to the hyperterminal. Below is the SCI configuration and associated ISR.

 

    // Configure the SCI0 module
    SCI0BDH = 0x01;                // bus clock = 8 Mhz
    SCI0BDL = 0xA1;                // baud rate = 1200 baud
    SCI0CR2_TE = 1;            // enable transmitter
    SCI0CR2_TIE = 1;            // enable transmitter interrupt

    EnableInterrupts;

    for(;:smileywink:;

 

    #pragma CODE_SEG __NEAR_SEG NON_BANKED
    interrupt void SCI0_ISR(void)
    {

        temp = SCI0SR1;               /* read the status register */

        SCI0DRL = 0x42;               /* write some data */

    }

    #pragma CODE_SEG DEFAULT

 

    VECTOR ADDRESS 0xFFD6 SCI0_ISR                    // in the .prm file

 

But the problem is, even though I read the status register as suggested by the Datasheet, the TC / TDRE flags never clear and the written data is never seen neither in the Data register nor on the hyperterminal. Infact what happens is, since the flags are not cleared, the CPU keeps on looping in the SCI ISR all the time unless some other interrupt occurs.

 

I also tired removing the debugger, changing baud rates, changing board jumper settings, hyperterminal settings, and many more stuff. I am using extremely slow Baud rates to avoid any other unwanted errors too. But still I am never able to get that data written into the SCI data register and send it successfully.

 

Please do help me out of this situation. Eagerly waiting for assistance.

 

Ameya Tipnis.

ラベル(1)
0 件の賞賛
返信
2 返答(返信)

863件の閲覧回数
DPB
NXP Employee
NXP Employee

Hello

 

There doesn't seem to be a problem with your code. It works here... transmitted 0x42 (ASCII 'B') to Hyperterm. I used 16MHz oscillator clock (8MHz bus) and the same settings... pasted  here below..... 

The start and end of the main function aren't clear in the original posting....but using those in the pasting below it works.

Is the 8MHz bus frequency visible (ECLK/PE4) ? 

Is  PS1 being used for the transmission ?

If so perhaps the part you have got damaged and you could try a second part..

 

void main(void) {   
  SCI0BDH = 0x01;                // bus clock = 8 Mhz
  SCI0BDL = 0xA1;                // baud rate = 1200 baud
  SCI0CR2_TE = 1;            // enable transmitter
  SCI0CR2_TIE = 1;            // enable transmitter interrupt
  EnableInterrupts;

  for(;:smileywink: {
  } /* loop forever */
}

 #pragma CODE_SEG __NEAR_SEG NON_BANKED
    interrupt void SCI0_ISR(void)
    {
        SCI0SR1;
        SCI0DRL = 0x42;               /* write some data */
  }

   #pragma CODE_SEG DEFAULT

 

DPB

0 件の賞賛
返信

863件の閲覧回数
AmeyaTipnis
Contributor I

Hello DPB,

 

Thank you very much for your reply. Indeed I was also wondering that if everything seems right, what might the problem be. Well I found the real problem to be somewhere else.

 

Since I am using a 64bit host machine, and Softec still does not have USB drivers for a 64 bit platform, I was compelled to use the Windows virtual PC environment running XP as an operating system and Codewarrior on it. Now it seems, hyperterminal was having issues accessing PC hardware through the 64 bit host system. Offcourse, I was not able to figure this out till I connected an oscilloscope on the TX pin, to find out that the SCI was indeed working correctly. Finally I installed another SSH client directly on the host PC OS, and it is working fine now.

 

I am having another issue though, regarding baud rate generator. The SCIBD register value and the generated baud rate are not in tune with each other. But I will try and find out the problem, once I am able to measure the bus clock (I am waiting for a high bandwidth DSO), and if needed I can always approach the forum.

 

Once again, thanks a lot for your help!!

 

Regards,

Ameya Tipnis.

0 件の賞賛
返信