Show Posts
Pages: 1 [2] 3 4
16  Using Arduino / Programming Questions / Re: Using AVR studio with an arduino sketch. on: February 19, 2011, 10:06:45 pm
So I changed the fuse bit settings for:
mega.bootloader.low_fuses=0xFF
mega.bootloader.high_fuses=0xDA
mega.bootloader.extended_fuses=0xF5

And its bricked, cannot enter programming mode. WTF!!!!!!!

#############################################################
mega.name=Arduino Mega (ATmega1280)

mega.upload.protocol=stk500
mega.upload.maximum_size=126976
mega.upload.speed=57600

mega.bootloader.low_fuses=0xFF
mega.bootloader.high_fuses=0xDA
mega.bootloader.extended_fuses=0xF5
mega.bootloader.path=atmega
mega.bootloader.file=ATmegaBOOT_168_atmega1280.hex
mega.bootloader.unlock_bits=0x3F
mega.bootloader.lock_bits=0x0F

mega.build.mcu=atmega1280
mega.build.f_cpu=16000000L
mega.build.core=arduino
17  Using Arduino / Programming Questions / Re: Using AVR studio with an arduino sketch. on: February 19, 2011, 08:58:35 pm
Ok the bootloader is on, no problems, now if I upload the makefile in avr studio will it overwrite the bootloader?
18  Using Arduino / Programming Questions / Re: Using AVR studio with an arduino sketch. on: February 19, 2011, 08:55:22 pm
Im in AVR studio right now. All im going to do is under the program -> flash -> input hex (bootloader file) same as you suggested, its listed in the arduino boards.txt...

Will the bootloader change any of my fuse settings? before I go ahead and hit program smiley
19  Using Arduino / Programming Questions / Re: Using AVR studio with an arduino sketch. on: February 19, 2011, 07:34:17 pm
Thats the thing though, how will the 1280 be able to understand the programming from the arduino IDE. I can't seem to find a proper bootloader anywhere.. if that is what I need.
20  Using Arduino / Programming Questions / Re: Using AVR studio with an arduino sketch. on: February 19, 2011, 01:42:00 pm
Doesn't matter what I use, I just need to be able to get the sketch that I wrote in the arduino IDE onto my new board. The arduino IDE I'd like to stay away from.
21  Using Arduino / Programming Questions / Re: Using AVR studio with an arduino sketch. on: February 19, 2011, 02:28:55 am
So far the only thing I could find was that the hex file generated doesn't work without the arduino bootloader, can anymore confirm? Would the ELF file work?
22  Using Arduino / Programming Questions / Re: My functions do not operate in order, why? on: February 18, 2011, 06:59:48 pm
not the prettiest but try that maybe?

if(x != 5)
{
pan();
x++
}
23  Using Arduino / Programming Questions / Re: My functions do not operate in order, why? on: February 18, 2011, 06:50:54 pm
Ok does it run correctly without delay();

and say get rid of move();
24  Using Arduino / Programming Questions / Re: My functions do not operate in order, why? on: February 18, 2011, 06:39:15 pm
Maybe use your pan function then a delay(1000); and then goto move();

// Pan servo algorithm
   
       pan();
       delay(1000);          // delay 1 second
       move(); 
 

or use the do while loop until a condition is met.

Hope that helps
25  Using Arduino / Programming Questions / Using AVR studio with an arduino sketch. on: February 18, 2011, 06:35:36 pm
So I just recently finished a standalone pcb utilizing the atmega1280 chip. I have wrote all the code in the arduino IDE. I would like to be able to use the existing code I have written and upload it through AVR studio 4. Last night I uploaded the *.hex file in avr studio that was generated in the arduino IDE but nothing seemed to work correctly. The atmega1280 of course has no bootloader, but from what i've read as long as your using the MKII you shouldn't need the bootloader. The hex file that I uploaded programmed fine but nothing was working correctly. There's an lcd, buttons, buzzers, mosfets... all that jazz. So I decided to try the bootloader. I used the atmega1280 bootloader supplied with the arduino IDE files, but it bricked the chip (Changed the fuse settings) - probably from my lack of experience. The only way to recover would be to use a HVPP I suppose.

I'm going to build another board today, but i don't want a repeat of last night. Will the hex file work without the bootloader, I see in avrstudio all the pins are mapped using a different method, not using the pinMode(53, OUTPUT); could this be what the bootloader assists with or is the bootloader just for say using a USB instead of a programmer like the MKII.

I have done lots of research but no straight forward answers that I can find. Any help is greatly Appreciated.

Also whats the *.ELF file  smiley-sad

Thanks a bunch
Geoff

26  Forum 2005-2010 (read only) / Syntax & Programs / Re: Reading multiple Digital Buttons on: September 21, 2010, 01:27:50 pm
Ok so I added the debounce, and played around with the code a bit its starting to look alright.

Thanks for the help smiley
27  Forum 2005-2010 (read only) / Syntax & Programs / Re: Reading multiple Digital Buttons on: September 20, 2010, 05:00:23 pm
Let me rephrase :-)

How does the break; command work?
28  Forum 2005-2010 (read only) / Syntax & Programs / Re: Reading multiple Digital Buttons on: September 20, 2010, 03:29:33 pm
You need some "break"s in your switch/ case, probably.


I had them all there but nothing, how does the break statement work, because I can't have it running through the same case the whole time, it will flicker my lcd text.
29  Forum 2005-2010 (read only) / Syntax & Programs / Re: Reading multiple Digital Buttons on: September 20, 2010, 03:28:13 pm
I don't know what you mean enabled the pull up resistors. the resistors are wired with a resistor in circuit so its low to start. I also changed the code to enable all the buttons as input but still the code doesn't seem right, nothing on the screen still when using the switch/cases.

Code:
 #include <string.h>
  #include <avr/pgmspace.h>
  #include "SystemFont5x7.h"    // system font
  #include <ks0108.h>           // LCD
  
  prog_char string_0[] PROGMEM =   "1. Enter User ID";  //0
  prog_char string_1[] PROGMEM =   "2. Thanks for the Input!";  //1
  prog_char string_2[] PROGMEM =   "3.";  //2
  prog_char string_3[] PROGMEM =   "4.";  //3
  prog_char string_4[] PROGMEM =   "5.";  //4
  prog_char string_5[] PROGMEM =   "6.";  //5
  prog_char string_6[] PROGMEM =   "7.";
  prog_char string_7[] PROGMEM =   "8.";
  prog_char string_8[] PROGMEM =   "9.";
  prog_char string_9[] PROGMEM =   "10.";
  prog_char string_10[] PROGMEM =   "11.";
  
  PGM_P PROGMEM StringTable[] =
  {
    string_0, string_1, string_2, string_3, string_4, string_5, string_6, string_7, string_8, string_9, string_10
  };

  
  #define escBtn 42
  #define button1 43
  #define button2 44
  #define button3 45
  
  int state[4];

  
  void setup()                    // run once, when the sketch starts
  {
    UnitSetup(); //get the screen up and running
    MainMenu();
  }
  
  void loop()                                       // run over and over again
  {

  }
  
  void MainMenu()
  {
    byte whichkey, Screen = 0;
    whichkey = PollKey();
    
    do
    {          
      switch(Screen)
      {
        case 1:
          GLCD.GotoXY(5,10);
          PrintLCD_P(0);          
          if (digitalRead(escBtn) == HIGH)
          {
            Screen++;
          }
        case 2:
          GLCD.GotoXY(5,10);
          PrintLCD_P(1);
          if (digitalRead(escBtn) == HIGH)
            {
              Screen++;
            }
        
        case 3:
        break;
      }
               
    } while (digitalRead(button1) != HIGH);
  }
  
  byte UnitSetup()
  {
    GLCD.Init(NON_INVERTED);   // initialise the library, non inverted turns on written pixels
    GLCD.ClearScreen();
    GLCD.SelectFont(System5x7);
      
    pinMode(escBtn,INPUT);    //set pin as input
    pinMode(button1,INPUT);
    pinMode(button2,INPUT);
    pinMode(button3,INPUT);
 
  }

  void PrintLCD_P(int which)
  {
     char buffer[21];
     strcpy_P(buffer, StringTable[which]);
     GLCD.Puts(buffer);
     delay(40);
  }
  
  char PollKey()
  {
    
    
    /*char whichkey;
    
    if (digitalRead(escBtn) == HIGH)
    {
      //whichkey = 1;
    }
    if (digitalRead(button1) == HIGH)
    {
      
    }
    if (digitalRead(button2) == HIGH)
    {
      
    }
    if (digitalRead(button3) == HIGH)
    {
      
    }

    
    return whichkey;*/
  }
30  Forum 2005-2010 (read only) / Syntax & Programs / Reading multiple Digital Buttons on: September 20, 2010, 03:07:10 pm
So im trying to create a menu interface on my lcd that I have. I've been doing lots of research and the code is driving me bonkers. I'm hoping im going in the right direction, im trying to make it so when a button is pressed it displays a number on the screen. As it sits right now im just trying to get a good way of reading what button was pressed and return a value to the main function. Any input is greatly appreciated.

As it is right now i think my case statement is wrong cause it displays both the text lines on the lcd and doesn't wait for the button input to change.

The  Code:
Code:
 #include <string.h>
  #include <avr/pgmspace.h>
  #include "SystemFont5x7.h"    // system font
  #include <ks0108.h>           // LCD
  
  prog_char string_0[] PROGMEM =   "1. Enter User ID";  //0
  prog_char string_1[] PROGMEM =   "2. Thanks for the Input!";  //1
  prog_char string_2[] PROGMEM =   "3.";  //2
  prog_char string_3[] PROGMEM =   "4.";  //3
  prog_char string_4[] PROGMEM =   "5.";  //4
  prog_char string_5[] PROGMEM =   "6.";  //5
  prog_char string_6[] PROGMEM =   "7.";
  prog_char string_7[] PROGMEM =   "8.";
  prog_char string_8[] PROGMEM =   "9.";
  prog_char string_9[] PROGMEM =   "10.";
  prog_char string_10[] PROGMEM =   "11.";
  
  PGM_P PROGMEM StringTable[] =
  {
    string_0, string_1, string_2, string_3, string_4, string_5, string_6, string_7, string_8, string_9, string_10
  };

  
  #define escBtn 42
  #define button1 43
  #define button2 44
  #define button3 45
  
  int state[4];

  
  void setup()                    // run once, when the sketch starts
  {
    UnitSetup(); //get the screen up and running
    MainMenu();
    pinMode(escBtn,INPUT);
  }
  
  void loop()                                       // run over and over again
  {

  }
  
  void MainMenu()
  {
    byte whichkey, Screen = 0;
    whichkey = PollKey();
    
    do
    {          
      switch(Screen)
      {
        case 1:
          GLCD.GotoXY(5,10);
          PrintLCD_P(0);          
          if (digitalRead(escBtn) == HIGH)
          {
            Screen++;
          }
        case 2:
          GLCD.GotoXY(5,10);
          PrintLCD_P(1);
          if (digitalRead(escBtn) == HIGH)
            {
              Screen++;
            }
        
        case 3:
        break;
      }
               
    } while (digitalRead(button1) != HIGH);
  }
  
  byte UnitSetup()
  {
    GLCD.Init(NON_INVERTED);   // initialise the library, non inverted turns on written pixels
    GLCD.ClearScreen();
    GLCD.SelectFont(System5x7);
      
    pinMode(escBtn,INPUT);        //set pin as input
 
  }

  void PrintLCD_P(int which)
  {
     char buffer[21];
     strcpy_P(buffer, StringTable[which]);
     GLCD.Puts(buffer);
     delay(40);
  }
  
  char PollKey()
  {
    
    
    /*char whichkey;
    
    if (digitalRead(escBtn) == HIGH)
    {
      //whichkey = 1;
    }
    if (digitalRead(button1) == HIGH)
    {
      
    }
    if (digitalRead(button2) == HIGH)
    {
      
    }
    if (digitalRead(button3) == HIGH)
    {
      
    }

    
    return whichkey;*/
  }
Pages: 1 [2] 3 4