S08PA4 SCI corrupted data problem

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

S08PA4 SCI corrupted data problem

Jump to solution
1,185 Views
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!

Labels (1)
0 Kudos
1 Solution
729 Views
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!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
5 Replies
729 Views
coztesor
Contributor I

what is your internal oscillator value?

trim the clock value in debugging mode.

0 Kudos
729 Views
JohnnyS2K
Contributor III

Hi coztesor,

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

Thanks!

0 Kudos
730 Views
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 Kudos
729 Views
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 Kudos
729 Views
vicentegomez
NXP TechSupport
NXP TechSupport

Good

Please let me know if you need more help.

Regards

0 Kudos