Michal Pochna

Problem with SCI in MC9S12P

Discussion created by Michal Pochna on Jun 18, 2012
Latest reply on Jun 20, 2012 by Michal Pochna

Hi everyone,


I'm trying to make SCI communication between uC and computer but I have a problem with receiving data using interrupt.

My SCI configuration:

  /* SCIBD: IREN=0,TNP1=0,TNP0=0,SBR12=0,SBR11=0,SBR10=0,SBR9=0,SBR8=0,SBR7=0,SBR6=0,SBR5=0,SBR4=1,SBR3=1,SBR2=0,SBR1=0,SBR0=0 */  SCIBD = 24U;                              /* SCICR1: LOOPS=0,SCISWAI=0,Rsrc=0,M=0,WAKE=0,ILT=0,PE=0,PT=0 */  SCICR1 = 0U;                                        /* SCISR2: AMAP=1 */  SCISR2 |= (unsigned char)128U;       /* Switch to the alternative register set */  /* SCIASR1: RXEDGIF=1,BERRV=0,BERRIF=1,BKDIF=1 */  SCIASR1 = 131U;                      /* Clear interrupt flags */  /* SCIACR1: RXEDGIE=0,BERRIE=0,BKDIE=0 */  SCIACR1 = 0U;                                        /* SCIACR2: BERRM1=0,BERRM0=0,BKDFE=0 */  SCIACR2 = 0U;                                        /* SCISR2: AMAP=0 */  SCISR2 &= (unsigned char)~(unsigned char)128U; /* Switch to the normal register set */  /* SCICR2: TIE=0,TCIE=0,RIE=1,ILIE=0,TE=1,RE=0,RWU=0,SBK=0 */  SCICR2 = 40U; 

 And this is how I try to handle an interrupt: 

  if(SCISR1 & 0x20)   {             SCISR1 ;    //SCICR2_RIE = 0;       recv_block();   }

 But program doesn't get into this section. I can see, when sending byte from computer, that RDRF flag is set, but condition never is considered as true - flag is immediately cleared. Sometimes program doesn't even get  into a interrupt procedure. 


Could you tell me what do I do wrong? I'll be grateful for eny help. 


Best regards,