Show Posts
Pages: [1] 2 3
1  Using Arduino / Programming Questions / Re: MEGA pins_arduino.h file question on: May 11, 2014, 02:57:22 am
Strange.... But they match with this....
http://arduino.cc/en/Hacking/PinMapping2560
2  Using Arduino / Programming Questions / Re: MEGA pins_arduino.h file question on: May 10, 2014, 02:37:37 pm
here is a table with the info
3  Using Arduino / Programming Questions / Re: MEGA pins_arduino.h file question on: May 10, 2014, 12:42:55 am
Yes it will! Thanks
4  Using Arduino / Programming Questions / MEGA pins_arduino.h file question on: May 10, 2014, 12:08:31 am
Does anyone know of a modified pins_arduino.h file for the mega2560 that allows you to access the 16 unmapped pins without using direct port?
5  Using Arduino / Programming Questions / Re: Simple Direct Port Manipulation Question on: May 09, 2014, 01:37:46 pm

However, that line of code generates a read-modify-write sequence so it has to be executed with interrupts disabled...

Code:
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
  PORTA = (PINA ^ (1 << ledPin));
}


So the fact that in the original code this was done in an ISR is why interrupts did not need to be disabled?
6  Using Arduino / Programming Questions / Re: Simple Direct Port Manipulation Question on: May 09, 2014, 12:08:44 am


Quote
DDRA ? (THAT DOES NOT COMPUTE)
I am using a MEGA board.

Quote
That's because there is only 3uS between ON and OFF. I don't think you can see that fast.
(hint: look at it with an Oscope on 2uS/DIV.
The code blinks the LED at a rate of 2Hz. It is very slow. It is my attempt at direct port manipulation that contains an error.
7  Using Arduino / Programming Questions / Re: Simple Direct Port Manipulation Question on: May 08, 2014, 11:40:39 pm
I tried this with not success.  LED just stays on.
Code:
#define ledPin PA4

void setup(){
DDRA = (1<<ledPin);
 
// initialize timer1
noInterrupts();           // disable all interrupts
TCCR1A = 0;
TCCR1B = 0;
TCNT1  = 0;

OCR1B = 31250;            // compare match register 16MHz/256/2Hz
TCCR1B |= (1 << WGM12);   // CTC mode
TCCR1B |= (1 << CS12);    // 256 prescaler
TIMSK1 |= (1 << OCIE1B);  // enable timer compare interrupt
interrupts();             // enable all interrupts
}

ISR(TIMER1_COMPB_vect){          // timer compare interrupt service routine
PORTA = (((PINA & (1<<ledPin)) ^ 1) << ledPin);//(ledPin, digitalRead(ledPin) ^ 1);   // toggle LED pin
}

void loop(){


}
8  Using Arduino / Programming Questions / Re: Simple Direct Port Manipulation Question on: May 08, 2014, 11:35:01 pm
I understand (somewhat) the bitwise XOR. Or are you saying that there is an error in the line of code below. Will this not toggle the stat of the pin?

 I need to know how to execute this line of code with the digitalread and write functions using direct port manipulation.

Code:
digitalWrite(ledPin, digitalRead(ledPin) ^ 1);   // toggle LED pin
9  Using Arduino / Programming Questions / Re: Simple Direct Port Manipulation Question on: May 08, 2014, 11:18:51 pm
Really??  Someone much smarter than me wrote it.. I got it from here
http://letsmakerobots.com/content/arduino-101-timers-and-interrupts

The example code works just fine just I would like to know how to execute that line of code if using direct port manipulation. Its is an XOR operation which changes the pin state of the LED every time it is called.

Code:
/* Arduino 101: timer and interrupts
   1: Timer1 compare match interrupt example
   more infos: http://www.letmakerobots.com/node/28278
   created by RobotFreak
*/

#define ledPin 13

void setup()
{
  pinMode(ledPin, OUTPUT);
  
  // initialize timer1
  noInterrupts();           // disable all interrupts
  TCCR1A = 0;
  TCCR1B = 0;
  TCNT1  = 0;

  OCR1A = 31250;            // compare match register 16MHz/256/2Hz
  TCCR1B |= (1 << WGM12);   // CTC mode
  TCCR1B |= (1 << CS12);    // 256 prescaler
  TIMSK1 |= (1 << OCIE1A);  // enable timer compare interrupt
  interrupts();             // enable all interrupts
}

ISR(TIMER1_COMPA_vect)          // timer compare interrupt service routine
{
  digitalWrite(ledPin, digitalRead(ledPin) ^ 1);   // toggle LED pin
}

void loop()
{
  // your program here...
}
10  Using Arduino / Programming Questions / Simple Direct Port Manipulation Question on: May 08, 2014, 10:40:45 pm
How would I execute this line of code with direct port Manipulation??

Code:
digitalWrite(ledPin, digitalRead(ledPin) ^ 1);   // toggle LED pin
11  Using Arduino / Programming Questions / Re: Programming MEGA2560 using USBasp/Arduino as programmer on: May 05, 2014, 07:39:15 am
Could there be something wrong with the code? Does the way you call the pins change if using a programmer?
12  Using Arduino / Programming Questions / Re: Programming MEGA2560 using USBasp/Arduino as programmer on: May 04, 2014, 06:25:34 pm
This might be dumb but put a 10uF capacitor between reset and ground on the uno.

Thanks, I ran down to radio shack and tried that yesterday. It did not seem to make a difference but I still have it wired uup that way.
13  Using Arduino / Microcontrollers / Re: Programming MEGA2560 using USBasp or Arduino as a programmer on: May 04, 2014, 06:24:00 pm
Did you connect the jumper wire from the UNO pin-10 to the Mega-RESET ?
Yes UNO pin 10 to Mega-RESET on the ICSP header

You DID select Arduino as ISP AFTER loading the ArduinoISP sketch (on the UNO) , right ?

Yes
14  Using Arduino / Microcontrollers / Re: Programming MEGA2560 using USBasp or Arduino as a programmer on: May 04, 2014, 05:55:52 pm
Thanks for your help. The issue is not unique to the USBasp. As I mentioned I get the same results using the Arduino UNO and MEGA as an ISP. Also, I am able to burn the bootloader with no problems. It is just when I attempt to upload software (blink) that I get nothing. I get no errors, which seems to mean that the software uploaded just fine.  However, the LED does not blink.
15  Using Arduino / Microcontrollers / Re: Programming MEGA2560 using USBasp or Arduino as a programmer on: May 04, 2014, 03:40:00 pm
yeah, I do wish that was it though smiley
Pages: [1] 2 3