Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
11 years, 7 months ago.
INTERRUPTS ENABLED AND DISABLED SERIAL
hi, i try to disabled an interrupt befores using it, after that i printf datas i want and after all of this i enabled again the interrupt, and the process repeat.(DISABLED, PRINTF, ENABLED)
BUT I CAN'T DISABLED THIS
IT CAN'T CONTROL THEM
THIS IS THE CODE
- include "mbed.h"
DigitalOut led1(LED1); DigitalOut led2(LED2); DigitalOut led3(LED3); DigitalOut led4(LED4);
Serial imu(p13, p14);
Serial xbee(p9,p10);
Serial pc(USBTX,USBRX);
void imurx_interrupt();
char rx_imu[218];
int m;
int aux2;
int aux;
int main(){
imu.baud(38400);
xbee.baud(9600);
pc.baud(9600);
imu.attach(&imurx_interrupt, Serial::RxIrq);
NVIC_EnableIRQ(UART1_IRQn);
NVIC_EnableIRQ(UART2_IRQn);
NVIC_EnableIRQ(UART3_IRQn);
m=1; aux=4;
while(1){
pc.printf("LAZO PIRNCIPAL\n\n");
led1=1;
wait_ms(20);
for (int i=0; i<220; i++) {
led4=!led4;
xbee.printf("%c",rx_imu[i]);
pc.printf("%c",rx_imu[i]);
if(i==218){
m=1;
pc.printf("SE IMPRIMIO EN EL LAZO PRINCIPAL\n\n");
NVIC_EnableIRQ(UART2_IRQn);
NVIC_EnableIRQ(UART3_IRQn);
} }
led1=0; } }
void imurx_interrupt(){
if(m==1){
if(imu.readable()&&(aux==4)){
led2=!led2;
wait_ms(5);
aux=4;
imu.gets(rx_imu,220);
pc.printf("ESTOY DENTRO:\n");
pc.printf("\n");
for (int i=0; i<220; i++) {
led3=!led3;
xbee.printf("%c",rx_imu[i]);
pc.printf("%c",rx_imu[i]);
if(i==218){
m=1;
pc.printf("SALI\n\n");
} }
aux2=3;
NVIC_DisableIRQ(UART2_IRQn);
NVIC_DisableIRQ(UART3_IRQn);
} } }