Go Down

Topic: Arduino Due Access Port (Read 2 times) previous topic - next topic

tarun31

Hi Guys,
Have a small doubt regarding the Due? How do we access the port to output a byte of data in parallel not using the serial port. Searched a lot but couldn't find a answer.

Thanks,
Tarun

Grumpy_Mike

Quote
How do we access the port to output a byte of data in paralle

Well it is a 32 bit processor so bytes are not on the menu.

Quote
Searched a lot but couldn't find a answer.

Section 32 in the processor data sheet tells you all about this.

tarun31

I understand that it is a 32 bit uC but if i wanted to output a byte of data in parallel what is the best way to do it without having to write a seperate function to seperate the byte into bits and then outputting seperately using digitalwrite for each pin. Any help would be very useful.
Thanks

Graynomad

#3
Dec 17, 2012, 01:32 pm Last Edit: Dec 17, 2012, 01:42 pm by Graynomad Reason: 1
I'm not that familiar with the SAM, but on an LPC to set any say 8 bits on a port you would do something like this

Code: [Select]
LPC_GPIO0->MASK = ~mask;
LPC_GPIO0->OUT = val << shift_bits;
LPC_GPIO0->MASK = mask;


IIRC the SAM code though does not uses pointers like that, it has direct defines like GPIO0_MASK etc.

Have a look through the Arduino-supplied source code for examples, there must be heaps.

Surely there's a SAM guru here that could answer this off the top of his head.

EDIT: Have a look in and around

<your install>\hardware\arduino\sam\system\CMSIS\Device\ATMEL\sam3xa\include\sam3x4e.h

All sorts of nifty #defines there.

ANOTHER EDIT: Try

<your install>\hardware\arduino\sam\system\CMSIS\Device\ATMEL\sam3xa\include\instance\instance_pioa.h

That looks like it has #defines for all the IO.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

tarun31

@Graynomad  Thanks a lot. Went through the header file and i found the required registers. Will give it a try and get back. Should do the work.

Tarun

Go Up