cfernandez
Joined: 18 Oct 2003 Posts: 145
|
STRANGE ERROR INT_RDA on PIC24 |
Posted: Fri Jun 03, 2011 12:42 am |
|
|
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;
}
}
} |
|
|