9-bit SCI Trouble

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

9-bit SCI Trouble

4,760 Views
RocK
Contributor I
I am having difficulty getting the 9th bit of the serial communication to be high during transmission. After setting the SCC3 register bit T8 to TRUE I then do a "AS1_SendChar(*Ptr)" in which I expect the 9th bit to be high. However, after looking at the transmission on a scope this is clearly not happening.

I realize I must be missing something so what must be done to ensure manipulation of this 9th bit.

Sincere thanks,
Rock
Labels (1)
0 Kudos
6 Replies

590 Views
ProcessorExpert
Senior Contributor III
Hello,
The SendChar method and both input and output buffers use the special type AS1_TComData that represents a character.
This type is declared according to the required width specified by AsynchroSerial bean property named 'Width'.
So to send a character with 9-bit message it's enough to just pass it as a unsigned int to the SendChar function. For example:

AS1_TComData x; // x is delared as a 16-bit word
...

x = 'a' | 0x100; // send a with 9-th bit set
AS1_SendChar(x);

best regards
Petr Hradsky
Processor Expert Support Team
UNIS
0 Kudos

590 Views
RocK
Contributor I
Petr Hradsky,

Thanks for the help, hopefully this post will help any other soul lucky enough to have to deal with a 9-bit protocol. I fortunately found the data type and guess my way to the answer on Friday and mistakenly didn't post my solution, my apologize.

Sincere thanks,
Rock

Message Edited by RocK on 2006-07-17 10:43 AM

0 Kudos

590 Views
RocK
Contributor I
UPDATE:

I seem to have found why setting the SCC3_T8 bit manually isn't working. Below is the ISR that has code which sets up SCC3_T8 for you. However, I am still not sure how to manipulate the 9th bit. I removed all the comments except for the line of code of interrest to improve readability.


Thanks,
Rock



/*
** ===================================================================
** Method : AS1_InterruptTx (bean AsynchroSerial)
**
** Description :
** The method services the receive interrupt of the selected
** peripheral(s) and eventually invokes the bean's event(s).
** This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
#define ON_FREE_TX 1
#define ON_TX_CHAR 2
ISR(AS1_InterruptTx)
{
byte OnFlags = 0;

if(SerFlag & RUNINT_FROM_TX) {
OnFlags |= ON_TX_CHAR;
}
SerFlag &= ~RUNINT_FROM_TX;
if(AS1_OutLen) {
AS1_OutLen--;
SerFlag |= RUNINT_FROM_TX;
(void)SCS1;
SCC3_T8 = (OutBuffer[OutIndxR] >> 8) & 1; /* Set the ninth bit */
SCDR = (byte)OutBuffer[OutIndxR];
if (++OutIndxR >= AS1_OUT_BUF_SIZE) {
OutIndxR = 0;
}
}
else {
OnFlags |= ON_FREE_TX;
SCC2_SCTIE = 0;
}
if(OnFlags & ON_TX_CHAR) {
AS1_OnTxChar();
}
if(OnFlags & ON_FREE_TX) {
AS1_OnFreeTxBuf();
; }
}
0 Kudos

590 Views
rhinoceroshead
Contributor I

What data type is OutputBuffer declared as?  If it is a char then there would be no ninth bit to set.

SCC3_T8 = (OutBuffer[OutIndxR] >> 8) & 1; /* Set the ninth bit */

Otherwise, this should work - provided that the SCI has been configured for 9 bit data.

0 Kudos

590 Views
RocK
Contributor I


rhinoceroshead wrote:

What data type is OutputBuffer declared as? If it is a char then there would be no ninth bit to set.


SCC3_T8 = (OutBuffer[OutIndxR] >> 8) & 1; /* Set the ninth bit */


Otherwise, this should work - provided that the SCI has been configured for 9 bit data.







Its is a word/unsigned int. Which tells me that I have to manipulate the first bit of the second byte in the transmitted data? I will try this and let you know, but please tell me what you think.


Sincere thanks,
Rock
0 Kudos

590 Views
rhinoceroshead
Contributor I
Okay, try replacing that line with this just as a test:
 
SCC3_T8 = ((unsigned int)(0x0100) >> 8) & 1; /* Set the ninth bit */
 
This should just send the 9th bit regardless of what data you really want to send.  If the bit shows up on the oscilloscope then you know that the configuration is good and that the code is working - which would mean the only reason you hadn't seen the pulse before is because the unsgined ints that you were sending just didn't happen to have a ninth bit as a 1.  If this test doesn't work, then you know that something has to be wrong with the SCI configuration.
0 Kudos