6 Replies Latest reply on Jul 31, 2012 7:42 AM by f.marcotulli

    68013A (128 pin) and USART0 Rx&TX Interrupts

    f.marcotulli

      Hi,

         

      I'm using this uC to control a RS232 port. I enabled the interrupt

         

      and I can read a received payload of 3 bytes by a vendor command and an interrupt routine.

         

      I have problem when I try to write because I suppose the interrupt routine is triggered, something goes wrong and the 

         

      uC won't answer. Could you help me?

         

      How do I manage the writing operation skipping the interrupt?

         

       

         

      This in the TD_Init:

         

       CPUCS = ((CPUCS & ~bmCLKSPD) | bmCLKSPD1) ; //Setting up the clock frequency

         

      SYNCDELAY;

         

       T2CON = 0x34 ;

         

      RCAP2H  = 0xFF ;

         

      RCAP2L = 0xD9;

         

      SCON0 = 0x5A ;

         

       Cont=0;

         

      IE|= bmBIT4;

         

       

         

      The interrupt routine:

         

       

         

      #include "fx2.h"

         

      #include "fx2regs.h"

         

      #include "fx2sdly.h"            // SYNCDELAY macro

         

      extern BYTE Cont;

         

      extern BYTE rbuf[10];

         

      void IRS_USART0(void) interrupt 4

         

      {

         

      if (RI != 0)

         

        {

         

        RI = 0;

         

        *(rbuf+Cont)=SBUF0;

         

        Cont++;

         

        if(Cont==3)

         

        Cont=0;

         

       }

         

      else if(TI!=0)

         

           TI=0;

         

      }

         
              
         
          THE VENDOR COMMAND    
         
          case V_READING:   
         

       

         

       

         

      while (TI == 0) ;

         

      TI = 0 ;

         

      SBUF0 = ch ;

         

      break;