Доброго времени суток!
Появилась проблема при работе с реальным PIC24f16ka101 Не могу включить прерывания по UART2
прописал
Код
void intUART2() iv IVT_ADDR_U2RXINTERRUPT ics ICS_AUTO {
if (U2RXIF_bit == 1) { // If interrupt is generated by RCIF
txt[i] = UART2_Read(); // Read data and store it to txrt string
i++; // Increment string index
if (i > 100) { // If index = 768,
i = 0; // set it to zero
ready = 1; // Ready for parsing GPS data
}
U2RXIF_bit = 0; // Set RCIF to 0
}
}
void main()
{
AD1PCFG = 0xffff; // initialize all A/D pins as Digital pins
//CLKdiv.RCDIV_0_bit = 0;
CM1CON = 0;
CM2CON = 0;
CLKDIV &= 0xF800; //äåëèòåëü â 0
TRISA = 0x0000; // Initial port A how output
TRISB = 0x0000; // Initial port B how output
LATA = 0;
LATB = 0;
TRISBbits.TRISB0 = 0; // Pin 1 RB0 U2TX Output GPS
TRISBbits.TRISB1 = 1; //Pin 2 RB1 U2RX Input GPS
TRISBbits.TRISB2 = 1; // Pin 3 RB2 U1RX Input GSM Ïîìåíÿòü ìåñòàìè Pin3 Pin8
TRISBbits.TRISB7 = 0; //Pin 8 RB7 U2TX Output GSM
UART1_Init(4800); // GSM
Delay_ms(1);
UART2_Init(4800); // GPS
Delay_ms(1);
//U1MODEbits.ALTIO = 1;
LATA.B1 ^= 1;
Delay_ms(5);
LATA.B1 ^= 1;
URXISEL_1_U2STA_bit = 0;
NSTDIS_bit = 1; // no nesting of interrupts
U2RXIF_bit = 0; // ensure interrupt not pending
U2RXIE_bit = 1; // Enable USART Receiver interrupt
while(1)
{
OERR_bit = 0; // Set OERR to 0
FERR_bit = 0; // Set FERR to 0
if (ready == 1)
{
ready = 0;
string = strstr(txt,"$GPGGA"); //NMEA message with coordinates is "$GPGGA" /see datasheet
if(string != 0) { // If txt array contains "$GPGGA" string we proceed...
// if(string[43] == '1') { // If "$GPGGA" NMEA message have '1' sign in the 43-th
// position it means that the GPS receiver has FIXed position!
latitude = (string[18]-48)*10 + (string[19]-48);
longitude = (string[30]-48)*100 + (string[31]-48)*10 + (string[32]-48);
if(string[28] == 'S') { // if the latitude is in the South direction it has minus sign
latitude = 0 - latitude;
}
if(string[41] == 'W') { // if the longitude is in the West direction it has minus sign
longitude = 0 - longitude;
// }
}
//UART1_Write_Text("Test GPS Ok"); // Latitude
UART2_Write_Text(latitude); // Latitude
UART2_Write_Text(longitude); // Longitude
}
UART1_Write_Text("Test GPS Ok");
}
}
}
где грабли