It is currently Fri Dec 19, 2014 12:55 pm



Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Question about Uno32 pinout...
PostPosted: Fri May 27, 2011 9:29 pm 
Offline

Joined: Thu May 26, 2011 6:19 pm
Posts: 4
Location: Brussels, Belgium
I'm searching a way to reduce the software changes in order to get existing shields working with the Uno32.

In many cases, pins 0 to 7 are used as a bidirectional 8 bit bus. I'm afraid those pins are mapped to a scramble set of D & F ports bits... not so easy to exchange 8 bit data through these pins then...

Something very strange, the pins 26 to 33 are well mapped to RE0 to RE7... so those pins are perfect to be used as a data bus... but they are located just beside the pins 0 to 7, and so it is not compatible with my shield...

Is it right?

Finally, perhaps I'm missing something and I'll be glad to get some explanation, or my understanding is correct and the Uno32 is not so compatible with existing Arduino shields...

Please tell me I'm wrong ;)


Top
 Profile  
 
 Post subject: Re: Question about Uno32 pinout...
PostPosted: Sat May 28, 2011 12:08 am 
Offline

Joined: Wed May 25, 2011 12:17 am
Posts: 148
I don't think you can expect too much compatibility below the arduino abstraction layer (and assuming that particular pins all belong to the same port is WAY below that layer. For instance, Arduino MEGA also has a scramble of different ports/bits for D0:7...)


Top
 Profile  
 
 Post subject: Re: Question about Uno32 pinout...
PostPosted: Sat May 28, 2011 3:48 pm 
Offline

Joined: Sat May 21, 2011 4:26 pm
Posts: 116
It is impossible to get the pin mappings the same. Even on different versions of AVR chips, the special purpose pins such as tx/rx spi pins, i2c pins, etc all move around. For example if you made a mega board with an Atmega128 it would not be compatible at the port level with the same board made with an atmeaga 1280.

Now through in a different manufacturer that has 16 bit ports instead of 8 bit ports, has there own arrangement of special pins to ports which ALSO varies from chip to chip and there is now way that you can get that level of compatibility.

Take for example code written for the Adruino UNO board that uses the ports directly. It will NOT work on a mega board, no way, no how. You have to re-map the pins. I have done this several times writing graphics drivers for various LCD boards.

As long as you use the abstraction layer (i.e. digitalWrite()) it will work fine. But of course, for such things as graphics drivers for an LCD board, this has a time penalty.

Mark


Top
 Profile  
 
 Post subject: Re: Question about Uno32 pinout...
PostPosted: Sat May 28, 2011 8:25 pm 
Offline

Joined: Thu May 26, 2011 6:19 pm
Posts: 4
Location: Brussels, Belgium
Finally I've modified the library to use the abstraction functions, easy for single bit control signals (R/W, CS and so on)... except for the data bus...

I have multiple shields using the pins 0 to 7 (scrambled through ports D and F) as bidirectional databus. Using digitalWrite/Read is not a good solution for me because of the speed. I would like to read/write very quickly the 8 bits... As far I know there is no abstraction function to do that, so I'm implementing home made solution. I evaluated the usage of bit shift & logical operation but it is still consuming too much time (I want to keep the CPU power for processing, not for stupid IO patching). So finally I'm moving to a solution using byte cross-ref const tables. It consumes Flash but it is very fast. Perhaps there is other solution, any other idea is welcome ;)

But again, it's very sad that pins 0 to 7 are mapped to RF & RD... while there is a pin to pin mapping between RE0->RE7 and pins 26 to 33, located just beside, same connector! It would have been so easiest to get it on pins 0 to 7 instead... :roll:

Perhaps a suggestion for the next version :idea:

By the way, I need to use Analog A0 to A5 as digital output. Abstraction functions do not allow to control them using digitalWrite, does it? So in my library, I'm using PORTSSetPinsDigitalOut, PORTClearBits and PORTSetBits on IOPORT_B... is it the right solution?

Thx,

/Phil


Top
 Profile  
 
 Post subject: Re: Question about Uno32 pinout...
PostPosted: Sat May 28, 2011 9:29 pm 
Offline

Joined: Wed May 25, 2011 12:17 am
Posts: 148
Quote:
I need to use Analog A0 to A5 as digital output. Abstraction functions do not allow to control them using digitalWrite, does it?

It should. (It does on AVR. There are constants defined so that you can do "digitalWrite(A0, HIGH)"; (do pinMode() first!))

If the RE port had been used for D0..7, it would have been impossible to put the PWM outputs in the same places they were on the Arduino, and those are more widely used than byte-wide IO. (ArduinoMEGA made the same decision: group all PWM pins together, rather than group ports together.)

It would be interesting to try to put together some max-speed byte-wide IO for assorted pin sets on the pickit boards. There are assorted weird things that you can do with a barrel shifter and/or 32bit multiply that might help. Better to do it once than have everyone attempt similar things separately.


Top
 Profile  
 
 Post subject: Re: Question about Uno32 pinout...
PostPosted: Sun May 29, 2011 3:32 am 
Offline

Joined: Sat May 21, 2011 4:26 pm
Posts: 116
Quote:
By the way, I need to use Analog A0 to A5 as digital output. Abstraction functions do not allow to control them using digitalWrite, does it? ?


Yes the analog pins can be used as outputs. you should be able to use the pins exactly the same as in Arduino/AVR.

i.e.
pinMode(14, OUTPUT); // 14 is A0
digitalWrite(14, HIGH);

or
pinMode(A0, OUTPUT); // 14 is A0


Top
 Profile  
 
 Post subject: Re: Question about Uno32 pinout...
PostPosted: Sun May 29, 2011 6:40 am 
Offline

Joined: Thu May 26, 2011 6:19 pm
Posts: 4
Location: Brussels, Belgium
yes it works! I pefer using A0 instead of pin number ;-) but it's cool, I've modified the library to use only abstraction functions instead of direct registry.

My "write to databus" function is working (writing a byte to pins 0 to 7), except for bits 0 & 1 (which are also connected to FTDI through resistors). I'm testing sending values from 0 to 255, each bit is toggling except 0 and 1 keeping high even I have configured pins 0 & 1 as output.

Is there any usage limitation related to pins 0 and 1? are they reserved by the bootloader?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Theme designed by stylerbb.net © 2008
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All times are UTC [ DST ]