Buy an Axon, Axon II, or Axon Mote and build a great robot, while helping to support SoR.
0 Members and 1 Guest are viewing this topic.
// Specify which board is being used.#include "sys/axon.h"#include "uart.h"#include "rprintf.h"#include "core.h"#include "timer.h"#include "a2d.h"#include "iopin.h"#include "pinChange.h"voidon_pinchange(const IOPin* io,boolean val, volatile void* data);voidappInitHardware(void){ pin_change_attach(C0, &on_pinchange, NULL);}TICK_COUNTappInitSoftware(TICK_COUNT loop_start){ return 0;}TICK_COUNTappControl(LOOP_COUNT loop_count, TICK_COUNT loop_start){ // NOP for 1 sec. return 1000000;}voidon_pinchange(const IOPin* io,boolean val, volatile void* data){ statusLED_off();}
What are you using to change the level on C0 to fire the pin change?
// Specify which board is being used.#include "sys/axon.h"#include "iopin.h"#include "pinChange.h"voidon_pinchange(const IOPin* io,boolean val, volatile void* data);voidappInitHardware(void){ pin_make_input(C0, 0); pin_change_attach(C0, &on_pinchange, NULL);}TICK_COUNTappInitSoftware(TICK_COUNT loop_start){ statusLED_off(); return 0;}TICK_COUNTappControl(LOOP_COUNT loop_count, TICK_COUNT loop_start){ return 20000;}voidon_pinchange(const IOPin* io,boolean val, volatile void* data){ statusLED_on();}
The ATMega640 only supports pin change interrupts on the following pins: PCINT0 - PCINT23 which correspond to IO pins:B0, B1, B2, B3, B4, B5, B6, B7, E0, J0, J1, J2 ,J3, J4, J5, J6, K0, K1, K2, K3, K4, K5, K6, K7You app uses 'C0' - which isn't in the list.In fact what you should see is the status LED flashing out an error message to tell you that your call to 'pin_change_attach' is specifying an invalid IOPin.
I'm not sure about those pin mappings you mention above, because the Axon doesn't have all of those. The Axon has - E2-E7, H2-H6, A0-A7 and C0-C7.
In fact what you should see is the status LED flashing out an error message to tell you that your call to 'pin_change_attach' is specifying an invalid IOPin.
QuoteIn fact what you should see is the status LED flashing out an error message to tell you that your call to 'pin_change_attach' is specifying an invalid IOPin.Webbot, I'm sure you've already thought of this and ruled it out but . . . can you somehow generate a compile warning when mistakes like these happen? My Axons are typically far away from me, or buried inside a robot, as I program it. I never notice flashing LEDs . . .And/or perhaps force the error to be outputted through serial, like the Axon USB port? There can always be a warnings(off) function if it causes people problems . . .(apologies if I just thread-jacked, its kinda related!)
If you think the UART error reporting idea is easiest, lets go with that. Its definitely more user friendly to output semi-informative text errors versus counting LED flashes.
Quote from: Admin on October 07, 2009, 07:55:52 PMIf you think the UART error reporting idea is easiest, lets go with that. Its definitely more user friendly to output semi-informative text errors versus counting LED flashes. They wont be informative text messages; they will report the error number (as per the number of flashes) e.g. 'WebbotLib Error 10'. It would be nice to have long descriptive pieces of text but they would bloat the program unnecessarily - all that text would need to be stored somewhere! So you would need to refer to "errors.h" to find a description of what error 10 refers to.