Still not luck. But I think mt problem is elsewhere , and I need to solve that issue before trying to sort the HALT out. I hope you can point me in the right direction
Here is the serial input routine, which is getting the correct info - if I print out flag (or remaction), the data is correct.
void remotecontrol(void) {
int q=0;
myled=!myled; /* just to let us know we are looping through here */
wait_ms(10);
if (remote.scanf("%s", remcon)) {
remaction=atoi(remcon);
}
/* here we flush everything to make sure that any garbage entries do not remain */
/* because what we got in from the serial link was not a valid string */
else {
for (q=0;q<8;q++) {
remcon[q]=(' '); /* clean it up for the next cycle */
remaction=0;
}
}
remcontoken=1; /* this tells us the command came from the r/control */
//printf("%d\n\r",remaction);
flag=remaction;
}
Here is the main loop
int main () {
NAOE=LOW; /* make sure the A6821's are disabled */
wait_ms(5);
initialize(); /* call the SBUS routine to clean things up */
powersw.fall(&power1);
Serial remote(NC, p27);
remote.baud(1200);
remote.format(8, Serial::None, 1);
remote.attach(&remotecontrol);
wait(1);
/* this is the main operating loop */
LOOP:
//printf("");
switch (flag) {
case 9211: volumecontrol();break; /* volume UP - uses same as volume DOWN*/
case 9221: volumecontrol();break; /* volume DOWN */
case 9231: inputselect();break; /* Input Select */
case 9241: mute_output();break; /* Mute */
case 9251: play();break; /* Play */
case 9261: power_on_off();break; /* power ON/OFF */
}
printf("%d____\n\r",flag);
flag=0; /* flush the flag since we finished the task */
//do{} while(flag==0); /* wait here */
//halt();
wait_ms(10);
goto LOOP;
}
Here are the problems:-
1. the rotatry encoders and p/buttons work correctly - these all activate IRQ's which go away and do stuff. For all of the IRQ's (except serial), I have a very short routine that simply assigns a number to the flag. The intention is that I then come back into main, execute the switch statement, and then ideally halt. for now I am just looping around LOOP GOTO. I tried a do{ } while(1) as well but that just hangs everything.
2. However, the input via the serial link does not work at all - no resoponse
3. The push button and rotatry encoder response is 'flaky'. Before I added the serial input roytine, they worked really well and were very tactile. now there's delays, sometimes they miss read etc.
I originally thought it was because of the LOOP GOTO, and was another reason for trying to HALT the mbed, but I have concluded it is because of something else.
Here is an example of my IRQ, this one for the power on/off p/button. The others are all similar, just the value assigned to flag changes
/*************** Power ON/OFF Interuppt **************/
void power1() {
wait_ms(10);
flag=9261;
// printf("power triggered");
}
Is it possible to put the mbed module into deep sleep mode and then to wake it up via any one of the port lines, if these have been set up as interrupts? Reason is to reduce power and also to reduce noise when th e controller is embedded in a sensitive analog application?
Andrew