Squirrels have fuzzy tails.
0 Members and 1 Guest are viewing this topic.
I had purchaser the Atmel AVRISP device, It will deliver on 12 March , When I plug in the device to my Axon II , It will auto deleted the bootloader ? If I using Project_Designer setup my program and load into AVR studio 4 , I have to load in the bootloader into Axon II or I can direct load the .hex file from my AVR studio 4 into Axon II and run the program code ?
PS: May I send it to you after this project, help me diagnostic it ?
I am from Malaysia , Asia too
#include "hardware.h"// Initialise the hardwarevoid appInitHardware(void) { initHardware();}// Initialise the softwareTICK_COUNT appInitSoftware(TICK_COUNT loopStart){ return 0;}// This is the main loopTICK_COUNT appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart) { // -------- Start Switch/Button------- // Switch/Button - see switch.h // To test if it is pressed then if(button.pressed()){ // pressed } // To test if it is released then if(button.released()){ // released } // -------- End Switch/Button------- // -------- Start Marquee------- { // A marquee is a 'Stream' so can use the print calls - // but need to end with '\n' to start scrolling // If the endDelay is non-zero then the marquee will scroll // forever or until you call: marquee.stop(); // If the endDelay is zero then the marquee will stop once // the entire line has been shown ('one-shot' mode) // In 'one-shot' mode then you may want to make sure that // a previous line has finished before you display a second line. // This can be done as follows:- marquee.setEndDelay(0); // Make sure we are in one-shot mode if(marquee.isActive()==FALSE){ if(loopCount==1){ marquee.print_P(PSTR("ABCDEFGHIJKLMNOPQRSTUVWXYZ\n")); }else{ marquee.print_P(PSTR("Loop=")); marquee.print(loopCount); marquee.println(); } } } // -------- End Marquee------- // -------- Start Analogue Output - PWM------- // The current duty cycle, ie the % time it is high, can be read as follows:- PERCENTAGE PWMduty = PWM.getPercent(); // Or it can be set to 75% using PWMduty = 75; PWM.setPercent(PWMduty); // -------- End Analogue Output - PWM------- // -------- Start Digital Output------- // Set the pin high D_OUTPUT_MA_1.high(); // Set the pin low D_OUTPUT_MA_1.low(); // Toggle the pin ie high->low, or low->high D_OUTPUT_MA_1.toggle(); // Output a high pulse of 1000us D_OUTPUT_MA_1.pulseOut(1000,TRUE); // -------- End Digital Output------- // -------- Start Digital Output------- // Set the pin high D_OUTPUT_MA_2.high(); // Set the pin low D_OUTPUT_MA_2.low(); // Toggle the pin ie high->low, or low->high D_OUTPUT_MA_2.toggle(); // Output a high pulse of 1000us D_OUTPUT_MA_2.pulseOut(1000,TRUE); // -------- End Digital Output------- // -------- Start Digital Output------- // Set the pin high D_OUTPUT_MB_1.high(); // Set the pin low D_OUTPUT_MB_1.low(); // Toggle the pin ie high->low, or low->high D_OUTPUT_MB_1.toggle(); // Output a high pulse of 1000us D_OUTPUT_MB_1.pulseOut(1000,TRUE); // -------- End Digital Output------- // -------- Start Digital Output------- // Set the pin high D_OUTPUT_MB_2.high(); // Set the pin low D_OUTPUT_MB_2.low(); // Toggle the pin ie high->low, or low->high D_OUTPUT_MB_2.toggle(); // Output a high pulse of 1000us D_OUTPUT_MB_2.pulseOut(1000,TRUE); // -------- End Digital Output------- // -------- Start Digital Input------- // Read the Digital Input (see iopin.h) and do something if(D_INPUT_LM1_1.isHigh()){ // The pin is high }else{ // The pin is low } // Measure the duration of a high pulse on an input pin TICK_COUNT pulse = D_INPUT_LM1_1.pulseIn(TRUE); cout << "Len=" << pulse << "\n"; // -------- End Digital Input------- // -------- Start Digital Input------- // Read the Digital Input (see iopin.h) and do something if(D_INPUT_LM1_2.isHigh()){ // The pin is high }else{ // The pin is low } // Measure the duration of a high pulse on an input pin TICK_COUNT pulse = D_INPUT_LM1_2.pulseIn(TRUE); cout << "Len=" << pulse << "\n"; // -------- End Digital Input------- // -------- Start Digital Input------- // Read the Digital Input (see iopin.h) and do something if(D_INPUT_LM2_1.isHigh()){ // The pin is high }else{ // The pin is low } // Measure the duration of a high pulse on an input pin TICK_COUNT pulse = D_INPUT_LM2_1.pulseIn(TRUE); cout << "Len=" << pulse << "\n"; // -------- End Digital Input------- // -------- Start Digital Input------- // Read the Digital Input (see iopin.h) and do something if(D_INPUT_LM2_2.isHigh()){ // The pin is high }else{ // The pin is low } // Measure the duration of a high pulse on an input pin TICK_COUNT pulse = D_INPUT_LM2_2.pulseIn(TRUE); cout << "Len=" << pulse << "\n"; // -------- End Digital Input------- // -------- Start Digital Input------- // Read the Digital Input (see iopin.h) and do something if(D_INPUT_LMC_1.isHigh()){ // The pin is high }else{ // The pin is low } // Measure the duration of a high pulse on an input pin TICK_COUNT pulse = D_INPUT_LMC_1.pulseIn(TRUE); cout << "Len=" << pulse << "\n"; // -------- End Digital Input------- return 0;}
// Its a component of the library#define BUILDING_LIBRARY// Include hardware info for this device #include <avr/io.h> #include <libdefs.h> #include <clock.h> #define CLOCK_PRESCALE 8 #define CLOCK_TOP 64000 // #define msPerTop (CLOCK_TOP*1000U*CLOCK_PRESCALE/F_CPU)#define msPerTop 32 #define usPerTop (msPerTop * 1000U) // convert to uS static volatile TICK_COUNT wholeTicks; #define CLOCK_INT_PENDING bit_is_set(TIFR1,OCF1A) #define CLOCK_INT_CLEAR sbi(TIFR1,OCF1A) #define CLOCK_INT_ENABLE sbi(TIMSK1,OCIE1A) #define CLOCK_INT_DISABLE cbi(TIMSK1,OCIE1A) #define CLOCK_TOP_REG OCR1A#include <errors.h> #define STATUS_LED_PORT PORTC #define STATUS_LED_INPUT PINC #define STATUS_LED_DDR DDRC #define STATUS_LED_PIN PC1 static uint8_t counter; void clockGetSnapshot(TIMER_SNAPSHOT* snapshot){ // Clock timer uses TIMER_MODE_CTC_OCR which generate compare interrupts on channel A CRITICAL_SECTION{ // get the current ticks from the timer uint16_t tcnt = TCNT1; // get the number of whole ticks snapshot->whole = wholeTicks; // get the current ticks again snapshot->part = TCNT1; // If the second reading of tcnt has gone down then there must have been an overflow // since reading the 'rtn' value. Or there may be a pending interrupt which may be // because interrupts are currently turned off. In either case increment the 'rtn' value // as if the interrupt has happened if(snapshot->part < tcnt || CLOCK_INT_PENDING ){ snapshot->whole += usPerTop; // get the current ticks again snapshot->part = TCNT1; } }}TICK_COUNT clockSnapshotToTicks(const TIMER_SNAPSHOT* snapshot){ TICK_COUNT rtn = snapshot->whole; // top = usPerTop // part x TICK_COUNT frac = snapshot->part; frac *= usPerTop; frac /= CLOCK_TOP; rtn += frac; return rtn;}// Get the current clock time in uSTICK_COUNT clockGetus(void){ TIMER_SNAPSHOT snapshot; clockGetSnapshot(&snapshot); return clockSnapshotToTicks(&snapshot);}// Initialise the clock timer and turn it onvoid __clockInit(void){ // Set interrupt pending = false CLOCK_INT_CLEAR; // Enable interrupts CLOCK_INT_ENABLE;}// ISR for clock overflow. Occurs every msPerTopISR(TIMER1_COMPA_vect) { wholeTicks += usPerTop; // Flash the status led if there is an error ERROR* err = &__error; if(err->errorCode && bit_is_set(STATUS_LED_DDR,STATUS_LED_PIN)){ // There is an error and status led pin is an output // Decrement any counter if(counter){ counter--; } if(counter==0){ // Its time to do something if(err->remaining==0){ err->remaining = ABS(err->errorCode); } uint8_t delay = (err->errorCode < 0 ) ? 250/msPerTop : 500/msPerTop; if(err->phase){ // turn led off if(-- err->remaining == 0){ delay = 2000/msPerTop; } }else{ // turn led on } err->phase = !err->phase; counter = delay; // toggle the LED sbi(STATUS_LED_INPUT,STATUS_LED_PIN); } } }
#include "../hardware.h"static const char PROGMEM name_button[] = "button";static const char PROGMEM name_uart1[] = "uart1";static const char PROGMEM name_led_display[] = "led_display";static const char PROGMEM name_marquee[] = "marquee";static const char PROGMEM name_PWM[] = "PWM";static const char PROGMEM name_D_OUTPUT_MA_1[] = "D_OUTPUT_MA_1";static const char PROGMEM name_D_OUTPUT_MA_2[] = "D_OUTPUT_MA_2";static const char PROGMEM name_D_OUTPUT_MB_1[] = "D_OUTPUT_MB_1";static const char PROGMEM name_D_OUTPUT_MB_2[] = "D_OUTPUT_MB_2";static const char PROGMEM name_D_INPUT_LM1_1[] = "D_INPUT_LM1_1";static const char PROGMEM name_D_INPUT_LM1_2[] = "D_INPUT_LM1_2";static const char PROGMEM name_D_INPUT_LM2_1[] = "D_INPUT_LM2_1";static const char PROGMEM name_D_INPUT_LM2_2[] = "D_INPUT_LM2_2";static const char PROGMEM name_D_INPUT_LMC_1[] = "D_INPUT_LMC_1";static const char PROGMEM unknown[] = "?";#define NUM_DEVICES 14static const void* PROGMEM tbl[]={ &_button_, name_button, &__C_uart1, name_uart1, &_led_display_, name_led_display, &_marquee_, name_marquee, _PWM_, name_PWM, _D_OUTPUT_MA_1_, name_D_OUTPUT_MA_1, _D_OUTPUT_MA_2_, name_D_OUTPUT_MA_2, _D_OUTPUT_MB_1_, name_D_OUTPUT_MB_1, _D_OUTPUT_MB_2_, name_D_OUTPUT_MB_2, _D_INPUT_LM1_1_, name_D_INPUT_LM1_1, _D_INPUT_LM1_2_, name_D_INPUT_LM1_2, _D_INPUT_LM2_1_, name_D_INPUT_LM2_1, _D_INPUT_LM2_2_, name_D_INPUT_LM2_2, _D_INPUT_LMC_1_, name_D_INPUT_LMC_1 };const char* getDeviceName(const void* device){ const char* rtn = unknown; for(int i=0 ; i<NUM_DEVICES*2; i+=2){ const void* addr = (const void*)pgm_read_word(&tbl[i]); if( addr == device){ rtn = (const void*)pgm_read_word(&tbl[i+1]); } } return rtn;}
hmmmm I don't quite understand your question/problem. What isn't working?Also, why not use WebbotLib v2? It writes all the code for you
I not sure that I had been set it as WebbotLib v2.08 or remain the V1.35
TICK_COUNT start_time Getus();TICK_COUNT duration=3000000; // 3secTICK_COUNT elapsed=0;while(1){elapsed = Getus() - start_time;//check the time passedif(elapsed>duration)//if the time passed is greater than 3 seconds { start_time = Getus();//reset the clock do_something();//run your code }}
g++ -g -Wall -DF_CPU=16000000 -mmcu=atmega640 -gdwarf-2 -fpack-struct -fshort-enums -funsigned-char -funsigned-bitfields -I"../../../../AxonII_2/webbotavrclib-2.08" -MD -MP -MT Code_2_main.o -MF dep/Code_2_main.o.d -fno-threadsafe-statics -c -o Code_2_main.o Code_2_main.cpp/usr/bin/sh: g++: command not foundmake: *** [Code_2_main.o] Error 127Build failed with 1 errors and 0 warnings...
Are you sure you installed gcc, and that it installed properly?Are there spaces in the pathname for where you installed it?Or did you install the latest tool set for AVR Studio? (don't do this; it messes up the path names and then you'll have to manually fix them)