SCI problem with DEMO9S08DZ60

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

SCI problem with DEMO9S08DZ60

1,995 次查看
dijonais
Contributor I

Hi,
I am working with DEMO9S08DZ60 and I the first thing I want to test is the SCI ports. But I don't know why I don't transmit anything either in port1 or port2. (I use the oscilloscope trying to see the output signal).
My easy code is below, hope you can help me a little bit with this. Thanks in advance.

#include <hidef.h>
#include "MC9S08DZ60.H"

void main( void )
{
  UINT8 data[9];

  /* disable COP */
  SOPT1 = 0x20;     /* disable COP, enable stop mode */

  /* Init Clock, Use PLL Engaged External mode, from 8MHz crystal -> 16 MHz bus */ 

  MCGC2 = 0x36;
  while (!MCGSC_OSCINIT);

  MCGC1 = 0xB8;
  while (!MCGSC_IREFST);      
  while(MCGSC_CLKST != 2);
 
  MCGC1 = 0x90;
  MCGC3 = 0x44;
  while(!MCGSC_PLLST);

  while (!MCGSC_LOCK);

  MCGC1 = 0x10;
  while(MCGSC_CLKST != 3);
 
  MCGC2_BDIV = 0;
  
  /* Enable interrupt */
  EnableInterrupts;       

    SCI2C1  = 0x40; 
    SCI2C2  = 0x0E;
    SCI2BDH = 0x00;
    SCI2BDL = 0x41;
    SCI2S2  = 0x00;
    SCI2C3  = 0x00; 

    SCI1C1  = 0x40; 
    SCI1C2  = 0x0E;
    SCI1BDH = 0x00;
    SCI1BDL = 0x41;
    SCI1S2  = 0x00;
    SCI1C3  = 0x00; 

  while(1)
    {
    SCI2D = 'U';
    SCI1D = 'U';
    }
}       /* main */

标签 (1)
0 项奖励
回复
4 回复数

1,011 次查看
kook
Contributor I

Hi all!

 

I have a problem with the same board. The baud rate is ok, it receives serial data, but it isn't able to transmit. There isn't any transition on PTE0 (viewed with an oscilloscope) and the TDRE bit in SCI1S1 register never sets. This thing is making me crazy. I don't understand what's wrong!

This is the routine:

 

 

            ORG    Z_RAMStart                   ; $0080

TEST            RMB     1


            ORG     ROMStart                    ; $1900

MyCode:     SECTION
main:
_Startup:

            JSR    MCU_init
                                                                                    
            LDHX   #$1080               ; initialize the stack pointer
            TXS

                BSET    5,PTCD
                BSET    3,PTBD
                CLRH
                CLRX
                                
                LDA     SCI1S1
LOOP     BRCLR   5,SCI1S1,LOOP
                LDA     SCI1S1                
                LDA     SCI1D          
                STA     TEST

                LDA     SCI1C2
                AND     #$F2
                ADD     #$04
                STA     SCI1C2
START   BSET    3,PTBD
                LDA     SCI1S1
LOOP1  BRCLR   7,SCI1S1,LOOP1
LOOP2  BRCLR   6,SCI1S1,LOOP2
                BCLR    5,PTCD
GIRO      BRSET   7,PTBD,GIRO
                BSET    5,PTCD
                LDA     SCI1S1
                LDA     SERIAL,X
                STA     SCI1D         
LOOP3   BRCLR   7,SCI1S1,LOOP3
LOOP4   BRCLR   6,SCI1S1,LOOP4
                BCLR    3,PTBD
                INCX
                TXA
                CBEQA   #$04,CLEAR
                JMP     OUT
CLEAR   CLRX
OUT        BRSET   6,PTBD,OUT
                JMP     START

                ORG     $A000
                
SERIAL          FCB     $35,$30,$36,$37

 

END.

 

 

 

 

The program loops here: LOOP3   BRCLR   7,SCI1S1,LOOP3

What is happening?

0 项奖励
回复

1,011 次查看
kook
Contributor I

Problem solved! It was a wrong wiring connection inside the PC case.

0 项奖励
回复

1,011 次查看
dijonais
Contributor I
Thanks,
I think I had a problem with reading the transmision flags.
Now it works correctly.
0 项奖励
回复

1,011 次查看
JimDon
Senior Contributor III
I suggest you use PE to set up the clocks and write the SCI code for you.
It is quite good at this. It will know what you have set for the clocks and will set up the baud rate correctly. Then you can look a the code.
0 项奖励
回复