SCI (trasmission)

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

SCI (trasmission)

10,669 Views
HCs08
Contributor I
I have some problems for the serial trasmisssion(SCI) with M68EVB908GB60UM and with MC13192SARDUG. The fundamental problem is that I do not succeed to write in the SCID (data register).
I have tried in this way (Ccode):
SCI1D = 0x39;
SCI1D = 'i'
SCI1D |= 0b00000111
but I have not had fortune.
Can you help me?
Thanks a lot.
Labels (1)
0 Kudos
Reply
12 Replies

2,503 Views
HCs08
Contributor I

Hi,

my problem is the same of Overdall, I have to send the result of ADC conversion with the SCI. I use polling for all my operation(SCI1S1_TDRE and ATDSC_CCF).  My question is about the formula for the baude rate:

baud rate=(busclock)/((sbr12-0)*16)

I want to modify the bus clock and I have this formula

bus frequency=((firg/7)*P*N/R)

What's firg? What's the value of firg for MC13192SARDUG and for M68EVB908GB60UM?

Thanks a lot

 

0 Kudos
Reply

2,503 Views
peg
Senior Contributor IV

Hi HCs08,

Presumably you want to use the internal clock mode FEI.

firg is the Frequency of the Internal Reference Generator.

In a 9S08GB/GT this is nominally 243kHz and you must trim it to be so by adjusting the value in ICGTRM until it is 243kHz

BR Peg

 

0 Kudos
Reply

2,503 Views
peg
Senior Contributor IV

Hi HCs08,

Firstly, writing to address SCI1D is all you have to do to send a byte out over SCI.

One thing to note is reading from this same address gives you the recieved register so the |= is probably not going to do what you expect.

You must however have initialised the SCI correctly before you can just write to SCI1D and expect it to work.

First you need to write to SCI1BDH and SCI1BDL to set the baudrate depending on your clock.

You can probably leave SCI1C1 at reset default of 0x00.

But you must at least set bit 3 in SCI1C2 for transmit enable and possibly bit 2 for receive enable.

Hope this helps.

BR Peg

BTW, please don't post the same Q in multiple forums and don't post Q's about devices in the general forum, you will only annoy people.

Message Edited by peg on 04-22-200601:01 PM

0 Kudos
Reply

2,503 Views
HCs08
Contributor I
Hi, I have read the answer. From what I have understood therefore the correct way to write SCID data register is this?
SCI1D = 0x39;
In order to write in the data register I must wait for  having flags TDRE and TC to 0?
I have also some problems with the bit of trasmission complete. To what it serves and when this comes 1? If I had to always transmit what  happens to bit TC?
Thanks a lot
0 Kudos
Reply

2,503 Views
peg
Senior Contributor IV

Hi,

Because the transmitter is double buffered you put a byte into SCID and it will automatically move it into the shift register when it can. So you just wait for TDRE to be set which means that this has occurred. You can then load SCID while it is busy shifting the previous byte out. This way you can easily achieve continuous transmission. TC gets set when the last bit has left the shift register.

This means that if you need to send several bytes you load the first one into SCID then wait for TDRE (which will be almost instantaneous the first time) then load the next byte into SCID then wait for TDRE etc...... You don't normally need to check for TC, only if you need to for instance disable the transmitter of a half duplex RS-485 line.

BR Peg

 

Message Edited by peg on 04-24-200611:04 PM

0 Kudos
Reply

2,503 Views
binarybrother
Contributor I
I do need to know when transmission is complete and I'm not clear on TDRE vs TC. 
 
The port is double buffered with the SCID register and a shift register. 
You write data to the SCID buffer.
The SCID data is transferred to the shift register and TDRE is set. 
When the shift register is empty AND SCID is empty then TC is set? 
 
Otherwise the TC and TDRE ints would be essentially identical.
 
??
 
Thanks
 
0 Kudos
Reply

2,503 Views
rocco
Senior Contributor II
Hi, Binary Brother:

You understand it correctly: TDRE indicates that you can load the next byte into the SCI. If you do that in a timely fashion, TC will never set. TC will only set when there is nothing left to send.

Most applications never need to use TC. The only time I have ever used TC was where the SCI was driving an RS485 bus. In that situation, I use TC to turn off the RS485 line driver.
0 Kudos
Reply

2,503 Views
binarybrother
Contributor I
Thanks Rocco.
 
Without giving away too much about my top secret super confidential consumer application: yes, you're exactly right.   A 485 line driver.
0 Kudos
Reply

2,503 Views
Odddlaw
Contributor I
Hi all,

I'm also having a little trouble setting up SCI Transmit Interrupt Routines on the QG8CPB.

1)What is the difference between TIE and TCIE?
2)What exactly triggers the interrupt?
3)How do you service the interrupt?


I've somehow managed to get inside the ISR but can't get out!
I'm simulating step by step using Full Chip Simulation, and I've also simulated through the BDM.

More over, what I want to do is to send the reading of the ADC and send it over to a PC via SCI.
I was thinking that the ADC ISR could write to the SCID, and that would trigger the communication? Do I actually need the TX interrupt?

If possible, the code for initializing and a simple ISR would be very much appreciated!!

Thanks a lot!!
0 Kudos
Reply

2,503 Views
peg
Senior Contributor IV

Hi Odddlaw,

SCTIE is the interrupt enable for SCTE which is the same as TDRE in a GB as described in my previous post. And TCIE is the interrupt enable for TC as in previous post.

You seem to be unsure of what you are doing with both interrupts in general and with using the SCI. I would suggest you get the SCI going in polled mode first to remove one layer of complexity.

Your answer to Q2 is found by using the info above combined with my previous post.

You don't need to use interrupts with the ADC because the conversion will be much quicker than to send the result over the SCI.

I would suggest this as a concept to start with.

cause a conversion

when complete (polled)

write result to SCI (just low byte for now to make it easy)

cause a conversion

when complete

* write to SCI

cause conversion

wait for SCTE

loop back to *

when you have that working you can put the stuff in the loop in a SCI interrupt routine so you can go and do something else.

This concept relies on the fact that sending one byte will take longer than 1 conversion so you don't need to wait for the conversion to end.

Let us know how you go!

BR Peg

Message Edited by peg on 04-26-200603:59 PM

0 Kudos
Reply

2,503 Views
Odddlaw
Contributor I
Thanks a lot peg!
Yes, I'm confused as to what exactly should the SCI interrupt do.


when you have that working you can put the stuff in the loop in a SCI interrupt routine so you can go and do something else.

What else?


I was thinking that in the SCI interrupt, sending the data out, however, this doesn't seem that adequate, since, who will trigger the interrupt (the SCI interrupt that is) to allow a transmission?

Again, many thanks!!!

Odddlaw.
0 Kudos
Reply

2,503 Views
peg
Senior Contributor IV

Hi,

To change my example above to interrupt:

1. Write ISR instead of loop:

read SCIxS1     ;to clear flag

write (ATD result low) to SCI

cause conversion

RTI

2. put the address of above routine into SC1x transmit vector.

3.  Enable interrupts and set TIE in SCIxC2

4. Sit back and watch it work!

BR Peg

 

0 Kudos
Reply