CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

STRANGE ERROR INT_RDA on PIC24

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
cfernandez



Joined: 18 Oct 2003
Posts: 145

View user's profile Send private message

STRANGE ERROR INT_RDA on PIC24
PostPosted: Fri Jun 03, 2011 12:42 am     Reply with quote

Hi,

We are porting our code from PIC18F8722 to PIC24HJ256GP206A and we found a big problem. When I use INT_RDA the kbhit not work.

I attach a simple program is you change

#define USE_INT FALSE

the variable PktIncoming tell me that not have more character, this is by the kbhit. But when we use change

#define USE_INT TRUE

the variable PktIncoming never change to TRUE.

Any can help me!!! Please!!!!

We are use the last version of compiler.

Thank you very much!!!

Best Regards,


Code:
#include <24HJ256GP206A.h>
#device *=16

#fuses FRC_PLL                  // Internal Fast RC oscillator with PLL
#fuses CKSFSM                   // Clock Switching is enabled, fail Safe clock monitor is enabled
#FUSES NOJTAG                    //JTAG disabled
#use delay( clock=80000000, type=INTERNAL, RESTART_WDT )




#use rs232(UART1,baud=115200,parity=N,bits=8,restart_wdt,errors,stream=COM1, )
#use rs232( xmit=PIN_B15, baud=115200, parity=N, bits=8, stream=DBG )


#byte U1STA = getenv("SFR:U1STA")
#bit URXDA = U1STA.0

static int8 Buffer[ 300 ];
static int16 Len=0;
static int8 PktIncoming=0;

#define USE_INT     TRUE

#if USE_INT
#int_RDA
#endif
void  RDA_isr(void)
{
    int16   lTimeOut = 55000;
   
    //
    // Read Character
    //
    if ( Len < 300 )
        Buffer[ Len++ ] = fgetc( COM1 );
   
    // Wait 10ms for next character
    while ( !kbhit( COM1 ) && lTimeOut-- );
//    while ( !URXDA && lTimeOut-- );

    // Exist other character?
    PktIncoming = !kbhit( COM1 );
//    PktIncoming = !URXDA;
}


void main()
{   
    int16 i;
   
    rs232_errors=0;
    #if USE_INT
    enable_interrupts(INTR_GLOBAL);
    #endif
    while( 1 )
    {
       #if USE_INT
            enable_interrupts(INT_RDA);
 //           delay_ms( 2000 );
       #else       
            if ( kbhit( COM1 ) )
                RDA_Isr( );
       #endif
       
      // If not exist more character show the capture data
      if ( PKtIncoming )   
        {
            disable_interrupts(INT_RDA);
            fprintf( DBG, "Inc:%u Len:%lu :", PktIncoming, Len );
            for ( i = 0 ; i < Len ; i++ )
                fprintf( DBG, "%02X", Buffer[ i ] );
            fprintf( DBG, "\n\r" );
           
            PktIncoming = Len = 0;
        }
    }

}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group