This is the other callback routine:
void rxCallback(void) {
static char nmea_in;
extern volatile int rec_state;
extern volatile char Rx_buffer[2000];
extern volatile int p_rx;
extern volatile int ais_ready;
int head;
Rx_buffer[p_rx++] = bg2.getc();
mled0 = 1;
nmea_in= bg2.getc();
switch (rec_state) {
case IDLE:
mled0 = 1;
break;
case SEARCH_START:
if (nmea_in == '$') {
mled1 = 1;
rec_state = CAPTURE;
}
break;
case CAPTURE:
garmin_buffer[item++] = nmea_in;
if(item >6){
head = analyze_buffer();
if(head == 17){
mled2 = 1;
gi++;
if(gi >= 2){
gi = 0;
mled0 = 0;
mled1 = 0;
mled2 = 0;
mled3 = 0;
}
rec_state = FETCH_DATA; we found our nmea sentence
}
else{
rec_state = SEARCH_START; not rigth sentence, go back to search rigth header
item = 0;
}
}
break;
case FETCH_DATA:
garmin_buffer[item++] = nmea_in;
if(item > 40){
packet_data_no_printf();
print_bg(&ais_2_garmin[0]);
print_pc(&ais_2_garmin[0]);
item = 0;
ais_ready = 17;
rec_state = SEARCH_START;
NVIC_DisableIRQ(UART2_IRQn);
}
break;
DEFAULT:
mled0 = 1;
break;
}
if(p_rx > 1100){
p_rx = 1100;
mled2 = 0;
}
}
There is a remainder " NVIC_DisableIRQ(UART2_IRQn); " that looks like it can do some harm, but it's actually disabling itself (wich doesn't happen.
I will try to remove it this evening, there is also a "mled1 = 0;" line wich I missed wich is probably the fault.
Ok thank you I have some hope for the future.
I need to get 3 serial channels working. They are working individually but I have serious problem to get them to work together so I started to write directly to the UARTs registers. It seems to work but at wrong speed. I need to know at what frequency the peripherals are running at to calculate the register settings.
I know they are normally set to 1/4 of the CPU speed which is supposed to be 100Mhz. I also know there is a way to measure the CPU clock speed but it's a little tricky for me to hit the tiny pin.
So does anybody know the frequencies for the UARTs?