MC9S08SH16 SCI Problem

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

MC9S08SH16 SCI Problem

746 Views
PabloA
Contributor II

Hi, I trying to use the SCI module in the MC9S08SH16 microcontroller with CW Development Studio, and while the transmission is working properly I can't receive anything.

 

This is the code created by Processor Expert 5.00 [04.48]:

 

/* ### Init_SCI init code */

 

/*SCIC2: TIE=0,TCIE=0,RIE=0,ILIE=0,TE=0,RE=0,RWU=0,SBK=0 */

SCIC2 = 0x00U; /* Disable the SCI module */

 

(void)(SCIS1 == 0U); /* Dummy read of the SCIS1 register to clear flags */

(void)(SCID == 0U); /* Dummy read of the SCID register to clear flags */

 

/* SCIS2: LBKDIF=1,RXEDGIF=1,RXINV=0,RWUID=0,BRK13=0,LBKDE=1,RAF=0 */

SCIS2= 0xC2U;

 

/* SCIBDH: LBKDIE=0,RXEDGIE=0,SBR12=0,SBR11=0,SBR10=0,SBR9=0,SBR8=0 */

SCIBDH= 0x00U;

 

/* SCIBDL: SBR7=0,SBR6=0,SBR5=0,SBR4=1,SBR3=1,SBR2=0,SBR1=0,SBR0=1 */

SCIBDL= 0x19U;

 

/* SCIC1: LOOPS=0,SCISWAI=0,Rsrc=1,M=0,WAKE=0,ILT=1,PE=0,PT=0 */

SCIC1= 0x24U;

 

/* SCIC3: R8=0,T8=0,TXDIR=0,TXINV=0,ORIE=0,NEIE=0,FEIE=1,PEIE=0 */

SCIC3= 0x02U;

 

/* SCIC2: TIE=0,TCIE=1,RIE=1,ILIE=0,TE=1,RE=1,RWU=0,SBK=0 */

SCIC2 = 0x6CU;

 

I made sure about Baudrate, SCI receive interrupts enable, SCI receive enable, pin conections, etc. 

If I test the port PTB0 ( If (PTBD_PTBD0 == 0) ) the data is incoming but It don't generate any interrupt.

 

Thanks for your time.

Regards.

Labels (1)
0 Kudos
4 Replies

404 Views
bigmac
Specialist III

Hello,

 

Your code snippet indicates to me that your baud rate is equal to the bus frequency, divide by 400.  For example, a baud rate of 19200 bits per second would require a bus freqiency of 7.68 MHz.  If you are using the internal reference to generate the bus clock, have you properly trimmed the internal reference frequency?  Oherwise, your baud rate will not be sufficiently accurate.

 

I notice that you have enabled transmission complete (TC) interrupt, receive interrupt, and framing error (FE) interrupt.  You will therefore need three separate ISR functions.  Perhaps you need to provide some additional code snippets for the interrupt handlers.  Why is TCIE enabled, and not TIE.

 

While the SCI module is enabled, this will over-ride the GPIO pins.  Therefore, reading PTBD0 should reveal nothing about the operation of the SCI.

 

Regards,

Mac

 

0 Kudos

404 Views
PabloA
Contributor II

Dear Bigmac, thank you very much for your interest.

 

The BUS frequency is fixed by an external Crystal of 4Mhz that generate 8Mhz of Internal BUS Clock.

When I see the transmission output it perfectly work at 20Kbps, my receiver processes the frame and reply with a 20Kbps serial word that I can see (by oscilloscope) in PTB0 but it don't generate any interrupt.

 

When I want to send my data buffer, I start sending the first byte. When it is sent, the transmission complete interrupt go on with the others. This is why using only TC Interrupt. It works fine without TIE enable.

 

The framing error interrupt is set because I wanted to know if at least the input signal generate any interrupt, but this did not work. I can't generate any interrupt with the receiver module.

 

I test the PTB0 GPIO by Software only to be sure that the signal are entering correctly.

 

I know that is very strange, but I'm going to change the chip and try again.

 

Any Idea?

 

Sorry about my writing.

 

Once again thank you very much for you time.

 

Regards.

 

Pablo.

0 Kudos

404 Views
bigmac
Specialist III

Hello,

 

I am glad that you found your problem.  Here is some additional clarification about one aspect -


PabloA wrote:

When I want to send my data buffer, I start sending the first byte. When it is sent, the transmission complete interrupt go on with the others. This is why using only TC Interrupt. It works fine without TIE enable.


One reason for using TIE, instead of TCIE, is to make use of the available double-buffering.  Using TCIE, any delays associated with the execution of other interrupts will potentially delay your data stream.  This need not occur if you use TIE, since the next character will be loaded to the buffer very soon after the previous character commences transmission, rather than at the conclusion of the previous character.

 

The usual purpose for TCIE is with a half-duplex transmission, such as RS-485.  You need to wait until the last send character is completely sent, before reverting to receive mode.

 

Regards,

Mac


 

0 Kudos

404 Views
PabloA
Contributor II

Dear Bigmac:

 

I Found the problem. It was my fault, I found a piece of Software where I was disabling the receiver.

 

It is good to know I can count with your help.

 

Thank you!

0 Kudos