Hi, I'm configuring the register of SCI about MC9S12G128 now. For easy to call the function of SCI0, SCI1 and SCI2, I declare a SCIx_TypeDef type of structure whose member variables are mapped with registers.
/* SCIx register base address */
#define SCI0 ((SCIx_TypeDef*)(0x000000C8UL))
#define SCI1 ((SCIx_TypeDef*)(0x000000D0UL))
#define SCI2 ((SCIx_TypeDef*)(0x000000E8UL))
typedef struct
{
volatile SCIBDSTR _BD;
volatile SCIACR2STR _ACR2;
volatile SCICR2STR _CR2;
volatile SCISR1STR _SR1;
volatile SCISR2STR _SR2;
volatile SCIDRHSTR _DRH;
volatile SCIDRLSTR _DRL;
}SCIx_TypeDef;
New a header file named SCI.h that is in the attachment, redeclare registers map that can be shared by SCI0, SCI1 and SCI2.
Then I write three functions for the test and the debug result is shown in an attachment.
void SCI_IrDAconfig_1(SCIx_TypeDef* SCIx)
{
SCIx->BD_IREN = 1;
SCIx->BD_TNP0 = 1;
SCIx->BD_TNP1 = 1;
}
void SCI_IrDAconfig_2(SCIx_TypeDef* SCIx)
{
SCIx->BD_IREN = 1;
SCIx->BD_TNP = 0x3;
}
void SCI_IrDAconfig_3(SCIx_TypeDef* SCIx)
{
SCIx->BD = 0xe000;
}
It seems that write a word(16-bit) or 2-bit operation is successful but write 1-bit operation is failed.
Why is that? Please give me some support. Many thanks!