Pages: [1]   Go Down
Author Topic: Programming a standalone ATMega328P with Arduino C`  (Read 176 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 149
Posts: 5618
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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

Santiago de Chile
Offline Offline
Sr. Member
****
Karma: 13
Posts: 431
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: August 31, 2014, 03:56:31 pm by mart256 » Logged

Work for what you love

Offline Offline
Newbie
*
Karma: 1
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

When you mean Arduino C do you mean:
Code:
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:
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.
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 149
Posts: 5618
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

When you mean Arduino C do you mean:
Code:
  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.

Logged

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

Pages: [1]   Go Up
Jump to: