Hi, I dont know how managed interrupts in mbed, I try to connect with a gps, and modem gprs and a module of mifare, but I dont want to wait in a while waiting for a character, so I try to manage with the interrupt like other microcontroller I use, like freescale and lpc1114 with lpcxpresso, this is my code
#include "mbed.h"
#include "TextLCD.h"
#include "gps.h"
TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD20x4); // rs, e, d4-d7
DigitalOut led1(LED1);
DigitalOut led2(LED2);
Serial gps(NC,p14);
Serial pc(USBTX,USBRX);
InterruptIn down(p21);
InterruptIn right(p22);
InterruptIn enter(p23);
InterruptIn left(p24);
InterruptIn up(p25);
GPS my_gps;
char buffer_gps[100];
int pointer_gps=0;
bool flag_gps=0;
/////////////////////////////////////////////////////////
void isr_gps(void){
led1=!led1;
if(gps.readable()){
buffer_gps[pointer_gps++]=gps.getc();
if(buffer_gps[pointer_gps-1]==0x0d){
led2=!led2;
flag_gps=1;
}
}
}
void clean_buffer_gps(void){
int i;
for(i=0;i<100;i++){
buffer_gps[i]=0x00;
pointer_gps=0;
}
}
/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
void menu_lcd(void){
lcd.cls();
lcd.locate(0,1);
lcd.putc('>');
lcd.locate(1,0);
lcd.printf("MENU DE USUARIO");
lcd.locate(1,1);
lcd.printf("Config. Tiempo");
lcd.locate(1,2);
lcd.printf("Config. Algo");
lcd.locate(1,3);
lcd.printf("Config. algo2");
}
///////////////////////////////////////////////////////
int main() {
gps.baud(4800);
gps.attach(&isr_gps,Serial::RxIrq);
my_gps.InitGPS();
menu_lcd();
while(1) {
if(flag_gps){//if received the final command 0x0d
flag_gps=0;
if(my_gps.ProcessDataGPS(buffer_gps)==gpgga_ok){
pc.printf("hora %s \n\r",my_gps.string_time);
clean_buffer_gps();
}else{
pc.printf("%s",buffer_gps);
clean_buffer_gps();
}
}
}
}
when I try to printf, all program crash, exist some way to disable the interrupt rx? best regards
Hi, I dont know how managed interrupts in mbed, I try to connect with a gps, and modem gprs and a module of mifare, but I dont want to wait in a while waiting for a character, so I try to manage with the interrupt like other microcontroller I use, like freescale and lpc1114 with lpcxpresso, this is my code
#include "mbed.h"
#include "TextLCD.h"
#include "gps.h"
TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD20x4); // rs, e, d4-d7
DigitalOut led1(LED1);
DigitalOut led2(LED2);
Serial gps(NC,p14);
Serial pc(USBTX,USBRX);
InterruptIn down(p21);
InterruptIn right(p22);
InterruptIn enter(p23);
InterruptIn left(p24);
InterruptIn up(p25);
GPS my_gps;
char buffer_gps[100];
int pointer_gps=0;
bool flag_gps=0;
/////////////////////////////////////////////////////////
void isr_gps(void){
led1=!led1;
if(gps.readable()){
buffer_gps[pointer_gps++]=gps.getc();
if(buffer_gps[pointer_gps-1]==0x0d){
led2=!led2;
flag_gps=1;
}
}
}
void clean_buffer_gps(void){
int i;
for(i=0;i<100;i++){
buffer_gps[i]=0x00;
pointer_gps=0;
}
}
/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
void menu_lcd(void){
lcd.cls();
lcd.locate(0,1);
lcd.putc('>');
lcd.locate(1,0);
lcd.printf("MENU DE USUARIO");
lcd.locate(1,1);
lcd.printf("Config. Tiempo");
lcd.locate(1,2);
lcd.printf("Config. Algo");
lcd.locate(1,3);
lcd.printf("Config. algo2");
}
///////////////////////////////////////////////////////
int main() {
gps.baud(4800);
gps.attach(&isr_gps,Serial::RxIrq);
my_gps.InitGPS();
menu_lcd();
while(1) {
if(flag_gps){//if received the final command 0x0d
flag_gps=0;
if(my_gps.ProcessDataGPS(buffer_gps)==gpgga_ok){
pc.printf("hora %s \n\r",my_gps.string_time);
clean_buffer_gps();
}else{
pc.printf("%s",buffer_gps);
clean_buffer_gps();
}
}
}
}
when I try to printf, all program crash, exist some way to disable the interrupt rx? best regards