How to use UART with PE(AsynchroSerial)?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

How to use UART with PE(AsynchroSerial)?

跳至解决方案
1,535 次查看
aaronlee
Contributor V

Hi,

How to use UART with PE(AsynchroSerial) in S12ZVCA?

Have any example?

Best Regards,

Aaron

标记 (4)
1 解答
990 次查看
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Aaron,

The correct code creates an instance of AS1_TComData and then the function takes the address of the instance as a argument. The wrong code creates only a pointer. But the pointer doesn't point anywhere.  

Regards,

Daniel

在原帖中查看解决方案

8 回复数
990 次查看
aaronlee
Contributor V

Hi Daniel,

I try to use Event of AS1_OnRxChar. It can work fine in DEBUG mode. But it can not work in NORMAL mode (remove MULTILINK then power off/on my board).

P.S. Main() code can work fine in both (DEBUG/NORMAL) mode.

void AS1_OnRxChar(void)
{
    AS1_TComData *ReceiveChar;
 /* Write your code here ... */
    AS1_RecvChar(ReceiveChar);
    switch(*ReceiveChar)
   {
       case 'C':
          Pin_DO3 = 1; // LED4 OFF
          Pin_RCK_DoorLock = 0; // Door Lock (Lo Active)
          setReg8(DDRS, 0xF3U);
          break;
       case 'O':
          Pin_DO3 = 0;// LED4 ON
          Pin_RCK_DoorUnlock = 0; // Door Unlock (Lo Active)
          setReg8(DDRS, 0xF5U);
          break;
       default:
          setReg8(DDRS, 0xF1U);
          break;
    }
   return;
}

AS1_OnRxChar.png

0 项奖励
990 次查看
aaronlee
Contributor V

My code as attachment

0 项奖励
990 次查看
aaronlee
Contributor V

Hi, Daniel,

I resolved the issue. But, I don't know why.

The wrong code as follow:

    AS1_TComData *ReceiveChar;
    AS1_RecvChar(ReceiveChar);
    switch(*ReceiveChar)

The correct code as follow:

    AS1_TComData ReceiveChar;
    AS1_RecvChar(&ReceiveChar);
    switch(ReceiveChar)

Best Regards,

Aaron

0 项奖励
991 次查看
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Aaron,

The correct code creates an instance of AS1_TComData and then the function takes the address of the instance as a argument. The wrong code creates only a pointer. But the pointer doesn't point anywhere.  

Regards,

Daniel

990 次查看
aaronlee
Contributor V

Hi Daniel,

Thank you so much! 

Best Regard,

Aaron

0 项奖励
990 次查看
aaronlee
Contributor V

Hi Daniel,

ZVL32-SCI-CW106 can work fine. Then, I modify SCI0 to SCI1 (ZVL32-SCI1-CW106 as attachment). It can work, too.

But, I got many error when I merge the SCI1.c & SCI1.h into my Processor Expert project(B0005_Test as attachment). I don't know how to solve the error.

Have any SCI (UART) example for Processor Expert?

 

Best Regards,

Aaron

0 项奖励
989 次查看
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

types byte and word are undefined.

You should define them in SCI1.h header file:

typedef unsigned char byte;
typedef unsigned int word;

Regards,

Daniel

0 项奖励
990 次查看
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Aaron,

If you use an evaluation board you can connect the UART via OSBDM to an USB host.

Read the detailed description of the attached example (in main.c).

 

Regards,

Daniel

0 项奖励