S08PA4 SCI corrupted data problem

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

S08PA4 SCI corrupted data problem

ソリューションへジャンプ
1,403件の閲覧回数
JohnnyS2K
Contributor III

Hi,


I have made a simple program on S08PA4 to send a single ASCII character at time (below), and this is incremented on each cicle of the main loop by the SCI. Happens that the data received by the terminal (docklight through a CP2102 USB to Serial Adapter) is always corrupted and shows other values as "ôõõôôõõöö÷÷öö÷÷ôôõõôôõõöö÷÷öö÷÷øøùùøøùùúúûûúúûûøøùùøøùùúúûûúúûûüüýýüüýýþþÿÿþþÿÿüüýýüüýýþþÿÿþþÿÿðôôõõôôõõöö÷÷öö÷÷ôôõõôôõõöö÷÷öö÷÷øøùùøøùùúúûûúúûûøøùùøøùùúúûûúúûûüüýýüüýýþþÿÿþþÿÿüüýýüüýýþþÿÿþþÿÿðôôõõôôõõöö÷÷öö÷÷" when it must show values like " !"#$%&'()*+`-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvxyz{|}~"

 

Below is the test application:

 

#include <hidef.h> /* for EnableInterrupts macro */ #include "derivative.h" /* include peripheral declarations */   #define LED PORT_PTBD_PTBD3   // internal oscillator calibration volatile unsigned char NV_TRIM @ 0xFF6E;   void main(void)  {   unsigned int Loop = 0;   volatile unsigned char TxC = 32;      /* System Options */   SYS_SOPT1 = 0b00001000; // only BKGD active   SYS_SOPT2 = 0b00000000;   SYS_SOPT3 = 0b00000000;      // disables WDT   WDOG_CNT = 0xC520;                           // write 0xC520 to the 1st unlock word   WDOG_CNT = 0xD928;                           // write 0xD928 to the 2nd unlock word   WDOG_CS1 = 0;                                // disable Watchdog   WDOG_CS2 = 0;   WDOG_TOVAL = 0xFFFF;   WDOG_WIN = 0x0000;            /*  System clock initialization */   /* Power Management */    PMC_SPMSC1 = 0; // disable LVD detect   PMC_SPMSC2 = 0;     /* ICS - Clock configuration */   // CPUCLK = 16MHz / BUSCLK = 8MHz     ICS_C1 = 0b00000100;   ICS_C2 = 0b00100000;   ICS_C3 = NV_TRIM;   ICS_C4_SCFTRIM = 1;     while(!ICS_S_LOCK); // wait to clock stabilize    SCI0_C1 = 0x00; // Reset flags    SCI0_C3 = 0x00; // Disable error interrupts   SCI0_C2 = 0x00; // Configure the SCI      SCI0_S2 = 0x00; // Clear status     SCI0_BD |= 52; // Set baud rate 9600 (8Mhz/(16 x 52))    SCI0_C1 |= 0x00;      SCI0_C2 |= (SCI0_C2_TE_MASK | SCI0_C2_RE_MASK); //  Enable transmitter, Enable receiver     PORT_PTBOE_PTBOE3 = 1; // enables output on LED pin     for(;;)    {      for(Loop=0;Loop<65000;Loop++);    LED = !LED;    if(TxC>127)    TxC = 32;   else    TxC++;    while ((SCI0_S1 & 0x80) == 0);  // wait for output buffer empty   SCI0_D = TxC;     }    }

 

This happens when I use the internal oscillator and external (4MHz crystal).

 

Does anyone had this problem before or can help me to find what is wrong?

 

 

Thanks!

ラベル(1)
0 件の賞賛
返信
1 解決策
947件の閲覧回数
vicentegomez
NXP TechSupport
NXP TechSupport

Hi

Please check this thread it can help you.

MC9S08PA4 SCI sample
Have a great day,
Vicente

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

元の投稿で解決策を見る

0 件の賞賛
返信
5 返答(返信)
947件の閲覧回数
coztesor
Contributor I

what is your internal oscillator value?

trim the clock value in debugging mode.

0 件の賞賛
返信
947件の閲覧回数
JohnnyS2K
Contributor III

Hi coztesor,

Sorry for the delay. On the program log appear the following line "TRIM=$0079,FTRIM=1".

Thanks!

0 件の賞賛
返信
948件の閲覧回数
vicentegomez
NXP TechSupport
NXP TechSupport

Hi

Please check this thread it can help you.

MC9S08PA4 SCI sample
Have a great day,
Vicente

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信
947件の閲覧回数
JohnnyS2K
Contributor III

Hi Vicente, now it worked!

I think my mistake really was the SCTRIM and SCFTRIM registers locations from the Non Volatile Memory that are incorrect, the correct locations are 0xFF6F for TRIM and 0xFF6E for the FTRIM.

Thank you!

0 件の賞賛
返信
947件の閲覧回数
vicentegomez
NXP TechSupport
NXP TechSupport

Good

Please let me know if you need more help.

Regards

0 件の賞賛
返信