sf
Joined: 02 Jul 2007 Posts: 9
|
18f1330 INT_RDA problem. |
Posted: Sat Jan 30, 2010 2:59 pm |
|
|
Hi, I'm trying to make this:
Code: |
#include <18F1330.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES H4 //High speed osc with HW enabled 4X PLL
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES NOBROWNOUT //No brownout reset
#FUSES BORV20 //Brownout reset at 2.0V
#FUSES PUT //Power Up Timer
#FUSES NOCPD //No EE protection
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES NOWRTC //configuration not registers write protected
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES MCLR //Master Clear pin enabled
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOCPB //No Boot Block code protection
#FUSES NOWRTB //Boot block not write protected
#FUSES BBSIZ1K //1K words Boot Block size
#FUSES FLTAA5 //FLTA multiplexed on A5
#FUSES T1OSCA6 //T1 oscillator pin on A6
#FUSES PWMPIN //PWM outputs disabled upon Reset
#FUSES HPOL_HIGH //High-Side Transistors Polarity is Active-High (PWM 1,3,5 and 7)
//PWM module high side output pins have active high output polarity
#FUSES LPOL_HIGH //Low-Side Transistors Polarity is Active-High (PWM 0,2,4 and 6)
//PWM module low side output pins have active high output polar
#use delay(clock=32000000)
#use rs232(baud=9600,parity=N,xmit=PIN_A2,rcv=PIN_A3,bits=8) |
Code: | #include "main.h"
#define BUFFER_SIZE 32
BYTE buffer[BUFFER_SIZE];
BYTE next_in = 0;
BYTE next_out = 0;
#int_RDA
void RDA_isr(void)
{
int t;
buffer[next_in]=getc();
t=next_in;
next_in=(next_in+1) % BUFFER_SIZE;
if(next_in==next_out)
next_in=t; // Buffer full !!
}
#define bkbhit (next_in!=next_out)
BYTE bgetc() {
BYTE c;
while(!bkbhit) ;
c=buffer[next_out];
next_out=(next_out+1) % BUFFER_SIZE;
return(c);
}
void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_CLOCK_DIV_2|ADC_TAD_MUL_0);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_comparator(NC_NC_NC);// This device COMP currently not supported by the PICWizard
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
printf("\r\n\Running...\r\n");
// The program will delay for 10 seconds and then display
// any data that came in during the 10 second delay
do {
delay_ms(10000);
printf("\r\nBuffered data => ");
while(bkbhit)
putc( bgetc() );
} while (TRUE);
}
|
But the interrupt never "fired"........
There is any problem with this pic? can someone else try this code to see if is my mistake?
Thanks in advance.
SF |
|