Society of Robots - Robot Forum
Software => Software => Topic started by: supernoob on October 15, 2009, 03:06:58 PM
-
hello, I just got an Axon and am messing with it trying a few things being i dont have much programing experiance.
The problem is with the delay function during the button press. the sensor readings display fine in terminal untill i hit the button then the program seems to freeze. Why is this? even if i just set up a program to count and display the numbers in terminal it does the same thing unless i use a for loop instead of delay_ms(1000).
#include "SoR_Utils.h"
int main(void)
{
configure_ports();
uartInit(); // initialize the UART (serial port)
uartSetBaudRate(1, 115200); //set UARTD speed, for USB
//initialize analog to digital converter
a2dInit();
//configure ADC scaling
a2dSetPrescaler(ADC_PRESCALE_DIV32);
//configure ADC reference voltage
a2dSetReference(ADC_REFERENCE_AVCC);
rprintfInit(uart1SendByte);//USB
rprintf(" Hello, I'm working!");
LED_on();
while(1)
{
if(button_pressed())
{
servo(PORTC,0,700);// move the servo
delay_ms(20);
}
int se0;//variable to hold the data of the sensor
se0=a2dConvert8bit(0);//get the data and store it in se0
rprintf("%d\n",se0);//send the data to terminal
}
return 0;
//End main
}
-
hmmm you are the second person to say this . . . I think a bug somehow creeped in the last code update . . .
For now just use delay_us() until I figure it out.
Sorry!
-
Cool thanx. delay_us works fine, so there must be a bug in delay_ms
-
supernoob, you will be my test subject.
Download the attached timer640.c and replace it with the one you have.
Try it and let me know if delay_ms() works again.
ps - I didn't try it myself, I just stole some code from AVRlib, put it in, and it compiles fine.
-
It seems to be working fine now with that timer640 file. Guess there was a bug somewhere in the other?
Thankyou for the help.
-
It seems to be working fine now with that timer640 file. Guess there was a bug somewhere in the other?
Thankyou for the help.
Okie. Just report back here if any other timer problems pop up!