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!