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

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

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;

0 Likes
6 Replies
Anonymous
Not applicable

 Hi,

   

 Try this 

   

 if(TI)

   

         {

   

 

   

if (n<=9)

   

      {

   

           SBUF0=EP2FIFOBUF;

   

           TI=0;

   

           n++;

   

      }

   

else

   

    {

   

            TI=0;

   

             n=0;

   

    }

   

}

   

Thanks

   

Prajith

0 Likes
Anonymous
Not applicable

 Hi, thx for your suggestion

   

but I need to test that in the vendor command

   

or in the interrupt routine?

0 Likes
Anonymous
Not applicable

     In Interrupt Service Routine.

0 Likes
Anonymous
Not applicable

 Ok,

   

but it's not clear how the uC manages the communication.

   

In RX I HAVE NOT problem.... because it's clear... for each BYTE I've an interrupt,

   

and I'll store the byte in a buffer and when the buffer will be complete I'll have my payload

   

(eventually I'll introduce a preamble and CRC...) 

   

 

   

But If I want to transmit a payload received by a Vendor Command

   

why I need to use the Interrupt?

   

It has no sense for me.

   

 

   

So with your example I need to write n>0in a correspondig vendor Command  to trigger the interrupt?

   

And only in the interrupt routine I'll write with SBUF=something?

   

Bye

0 Likes
Anonymous
Not applicable

 Hi,

   

  You can do it either using interrupt as explained in http://www.cypress.com/?id=4&rID=55681 or by checking endpoint buffer flags as in http://www.cypress.com/?rID=40248.

   

Thanks

   

Prajith

0 Likes
Anonymous
Not applicable

I'm going to study this examples.

   

Thx for you help!!!

0 Likes