Go Down

Topic: Programming a standalone ATMega328P with Arduino C` (Read 214 times) previous topic - next topic

VishalSubramanyam

I have a doubt. I want to know whether programming a standalone Arduino Bootloader loaded ATMega328P with Arduino C language instead of the standard C language would work. I mean instead of writing a port number like DDRB = 0b00000001 with just 13 would work. I will use the following USB programmer: http://www.ebay.com/itm/AVR-USBasp-Programmer-for-AVR-Microcontrollers-/281424409513?_trksid=p2054897.l5668.

I also want to know how to use that programmer. Should I just fit in my ATMega328P into the Microcontroller slot you see in the picture on Ebay (The site is in the above link).

fungus


I have a doubt. I want to know whether programming a standalone Arduino Bootloader loaded ATMega328P with Arduino C language instead of the standard C language would work.


Yes.


I also want to know how to use that programmer. Should I just fit in my ATMega328P into the Microcontroller slot you see in the picture on Ebay (The site is in the above link).


No, it goes on the end of the grey cable.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

mart256

#2
Aug 31, 2014, 10:54 pm Last Edit: Aug 31, 2014, 10:56 pm by mart256 Reason: 1
You can program atmega328p with Arduino C. (First set the fuses).

To program with programmmer conect the atmega328p to the conector (not the socket/slot, dont remove that microcontroller because its the core of the programmer). The conector is called avr isp and it has two versions, isp 10 pins and isp 6 pins. Both work the same way, just google "avr isp pinout", and then google "atmega328p" pinout . You have to connect MISO, MOSI, SCK, VCC , GND and RESET.

VishalSubramanyam

When you mean Arduino C do you mean:
Code: [Select]

int led = 13;
setup() {               
 
  pinMode(led, OUTPUT);     
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}

Instead of :
Code: [Select]

int main(void) {

DDRC |= (1<<5);
while (1) {

PORTC |= (1<<5);

_delay_ms(500);

PORTC &= ~(1<<5);
//wait 0.5 sec
_delay_ms(500);
}
}

I mean like not using Data Direction Register and PORT. That would be awesome.

fungus


When you mean Arduino C do you mean:
Code: [Select]

  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second


Yes.

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Go Up