Author Topic: arduino due port manipulation  (Read 9817 times)

0 Members and 1 Guest are viewing this topic.

Offline electronics manTopic starter

  • Frequent Contributor
  • **
  • Posts: 686
  • Country: gb
arduino due port manipulation
« on: June 15, 2015, 02:13:48 pm »
I'm trying to measure the speed of an arduino due like in this video

however the PORTB = B0010000; doesn't work on the due, I would like to know how i can manipulate an arduino dues ports.
follow me on twitter @get_your_byte
 

Offline shebu18

  • Frequent Contributor
  • **
  • Posts: 309
  • Country: ro
Re: arduino due port manipulation
« Reply #1 on: June 15, 2015, 02:37:27 pm »
Hy,

The Due has an ARM processor and the mini in the video has a atmega328 they are totally different.
The schematic for the due http://www.arduino.cc/en/uploads/Main/arduino-Due-schematic.pdf shows you that PB5 is connected to Ethernet, so you will not see any pin changes. The 5th pin is connected to PC25. PA, PB and PC are 32bit ports, not 8bit. For manipulating it you would need to write PORTC = B00000000000000000000000000010000.

You could try PORTB &= 0xFFFFFFEF
PORTB |= 0xFFFFFFFF
« Last Edit: June 15, 2015, 02:39:41 pm by shebu18 »
 

Offline bobcat

  • Regular Contributor
  • *
  • Posts: 94
  • Country: us
Re: arduino due port manipulation
« Reply #2 on: June 15, 2015, 06:40:10 pm »
To toggle PWM5 on Arduino Due after setting as output:

PIOC->PIO_SODR=(1u<<25); // Set Pin High
PIOC->PIO_CODR=(1u<<25); // Set Pin Low

You may want to add a delay between the Set commands because it will be fast.


« Last Edit: June 15, 2015, 07:09:56 pm by bobcat »
 

Offline retrolefty

  • Super Contributor
  • ***
  • Posts: 1648
  • Country: us
  • measurement changes behavior
Re: arduino due port manipulation
« Reply #3 on: June 15, 2015, 07:33:59 pm »
Just as a side bar, there are more then 14 (0-13) digital pins available on your nano by utilizing the six analog input pins as digital pins. This can be done either by using pin names as follows:

digitalWrite(A0, HIGH);
or
digitalWrite(14, HIGH);

If one just wants to generate a fixed square wave at the highest possible frequency one can utilize one of the timers to directly drive a output pin using internal hardware, and I seem to recall that the fastest speed possible will be 1/2 the clock rate, so 8 MHz for a 16 MHz clock.
« Last Edit: June 15, 2015, 07:36:06 pm by retrolefty »
 

Offline electronics manTopic starter

  • Frequent Contributor
  • **
  • Posts: 686
  • Country: gb
Re: arduino due port manipulation
« Reply #4 on: June 15, 2015, 11:10:48 pm »
Hy,

The Due has an ARM processor and the mini in the video has a atmega328 they are totally different.
The schematic for the due http://www.arduino.cc/en/uploads/Main/arduino-Due-schematic.pdf shows you that PB5 is connected to Ethernet, so you will not see any pin changes. The 5th pin is connected to PC25. PA, PB and PC are 32bit ports, not 8bit. For manipulating it you would need to write PORTC = B00000000000000000000000000010000.

You could try PORTB &= 0xFFFFFFEF
PORTB |= 0xFFFFFFFF
1, due doesn't have Ethernet
2, port manipulation doesn't work like that for the due it is a totally different syntax but i don't know what the syntax is
follow me on twitter @get_your_byte
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf