EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Setting PIO pins.

Started by Phill November 18, 2010
Hi there,

I've just started playing with ARMs, having just bought the AT91SAM7S-EK. I've done some simple LED flashing programs and hav got Chan's FatFS running on the board having soldered on a SD/MMC connector.

However now I want to try and interface the ARM to another micro through a buffer chip so that I can use the ARM as a SD/MMC controler.

I have looked at the datasheet and done some google searching and I understand how to set a block of pins as inputs or outputs and enable pullups etc by writing 1s to the relevant set or clear registers to set the ports up.

However what I am not clear on is that if I wanted to say send a byte of data to PA0..PA7 would I have to do two writes firstly writing the byte to the set register to set the bits I wanted as high and then inverting it and writing to the clear register to clear the bits I wanted as low ?

In the past I have used micros like the AVR where you can just write an absolute byte to a port and it will appear as written.

If not as I'm writing in C I guess I could setup a macro or inline function to do the required bit twidling (if one does not already exist) it just seems a little bit of an odd way of doing it :)

One last question, the AT91SAM7s256 datasheet has 2 UARTS shown on the block diagram, but in the section about the UART it onlys talks about UART0, should I assume that UART1 is the debug unit UART ?

Cheers.

Phill.

Phill
Have a look at the 'Synchronous Data Output' subsection of the
'Parallel Input/Output Controller (PIO)' section of the data sheet. It
will explain what you will need to do. I have an old copy of the data
sheet so any page number I give you are likely to be incorrect.

Regards
-Bill Knight
R O SoftWare
On 11/17/2010 3:06 PM, Phill wrote:
> Hi there,
>
> I've just started playing with ARMs, having just bought the AT91SAM7S-EK. I've done some simple LED flashing programs and hav got Chan's FatFS running on the board having soldered on a SD/MMC connector.
>
> However now I want to try and interface the ARM to another micro through a buffer chip so that I can use the ARM as a SD/MMC controler.
>
> I have looked at the datasheet and done some google searching and I understand how to set a block of pins as inputs or outputs and enable pullups etc by writing 1s to the relevant set or clear registers to set the ports up.
>
> However what I am not clear on is that if I wanted to say send a byte of data to PA0..PA7 would I have to do two writes firstly writing the byte to the set register to set the bits I wanted as high and then inverting it and writing to the clear register to clear the bits I wanted as low ?
>
> In the past I have used micros like the AVR where you can just write an absolute byte to a port and it will appear as written.
>
> If not as I'm writing in C I guess I could setup a macro or inline function to do the required bit twidling (if one does not already exist) it just seems a little bit of an odd way of doing it :)
>
> One last question, the AT91SAM7s256 datasheet has 2 UARTS shown on the block diagram, but in the section about the UART it onlys talks about UART0, should I assume that UART1 is the debug unit UART ?
>
> Cheers.
>
> Phill.
On Wed, Nov 17, 2010 at 10:06 PM, Phill wrote:
>
> Hi there,
>
[SNIP]
> One last question, the AT91SAM7s256 datasheet has 2 UARTS shown on the block diagram, but in the section about the UART it onlys talks about UART0, should I assume that UART1 is the debug unit UART ?
>

The debug serial port is the DBGU interface, the AT91SAM7S256 has two
USART interfaces, take a look at the Table 10-3 of the datasheet for
where are multiplexed this pins.

Regards
Pietro
Quoting Bill Knight :

> Phill
> Have a look at the 'Synchronous Data Output' subsection of the
> 'Parallel Input/Output Controller (PIO)' section of the data sheet. It
> will explain what you will need to do. I have an old copy of the data
> sheet so any page number I give you are likely to be incorrect.

Thanks Bill,

that's exactly the sort of thing I needed.

Another question has just occoured to me, if I configure my pins as
outputs, open drain enabled, and pullups enabled, if I then set them to
1 would I be able to read the pins as inputs if I drive them externally?
This would be good as it would save me having to keep switching them
between inputs and outputs....

Cheers,

Phill.

----------------------------
This message was sent using IMP, the Internet Messaging Program.

Go to http://kwikbyte.com/KB9260.html and download their sample code for starters.

R.

--- In A..., "Phill" wrote:
>
> Hi there,
>
> I've just started playing with ARMs, having just bought the AT91SAM7S-EK. I've done some simple LED flashing programs and hav got Chan's FatFS running on the board having soldered on a SD/MMC connector.
>
> However now I want to try and interface the ARM to another micro through a buffer chip so that I can use the ARM as a SD/MMC controler.
>
> I have looked at the datasheet and done some google searching and I understand how to set a block of pins as inputs or outputs and enable pullups etc by writing 1s to the relevant set or clear registers to set the ports up.
>
> However what I am not clear on is that if I wanted to say send a byte of data to PA0..PA7 would I have to do two writes firstly writing the byte to the set register to set the bits I wanted as high and then inverting it and writing to the clear register to clear the bits I wanted as low ?
>
> In the past I have used micros like the AVR where you can just write an absolute byte to a port and it will appear as written.
>
> If not as I'm writing in C I guess I could setup a macro or inline function to do the required bit twidling (if one does not already exist) it just seems a little bit of an odd way of doing it :)
>
> One last question, the AT91SAM7s256 datasheet has 2 UARTS shown on the block diagram, but in the section about the UART it onlys talks about UART0, should I assume that UART1 is the debug unit UART ?
>
> Cheers.
>
> Phill.
>

On 11/18/2010 10:58 AM, a...@aurigae.demon.co.uk wrote:
> Quoting Bill Knight:
>
>> Phill
>> Have a look at the 'Synchronous Data Output' subsection of the
>> 'Parallel Input/Output Controller (PIO)' section of the data sheet. It
>> will explain what you will need to do. I have an old copy of the data
>> sheet so any page number I give you are likely to be incorrect.
>
> Thanks Bill,
>
> that's exactly the sort of thing I needed.
>
> Another question has just occoured to me, if I configure my pins as
> outputs, open drain enabled, and pullups enabled, if I then set them to
> 1 would I be able to read the pins as inputs if I drive them externally?
> This would be good as it would save me having to keep switching them
> between inputs and outputs....
>

Phill
Have a look at the 'Multi Drive Control (Open Drain)' and 'Inputs'
subsections that follow after the 'Synchronous Data Output' one.
-Bill
Yes, you can use the PDSR register to read the actual value on the I/O pins, but the low to high transitions are going to be fairly slow because of the weak pullups in the processor. You can speed that up somewhat by adding external pullups, but you're going to be limited there as well due the max sink current of the outputs.

Depending on what you're doing, a sluggish rise time may not be a big deal, but if you're trying to do high speed I/O you're going to need to do some calculations to see if open drain will work.

Cliff

--- In A..., afra@... wrote:
>
> Another question has just occoured to me, if I configure my pins as
> outputs, open drain enabled, and pullups enabled, if I then set them to
> 1 would I be able to read the pins as inputs if I drive them externally?
> This would be good as it would save me having to keep switching them
> between inputs and outputs....
>
> Cheers,
>
> Phill.
>
> ----------------------------
> This message was sent using IMP, the Internet Messaging Program.
>


The 2024 Embedded Online Conference