Loading...
Pages: 1 [2] 3   Go Down
Author Topic: Fast digital I/O, software I2C, and software SPI libraries  (Read 2382 times)
0 Members and 1 Guest are viewing this topic.
Rapa Nui
Offline Offline
God Member
*****
Karma: 16
Posts: 881
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am suggesting the mighty layout (you already did above) - for all DIP40 chips: 16/32/324/64/644/1284.
The 32U4 is not available in DIL40, afaik..

Code:
#elif defined(__AVR_ATmega1284P__)\
|| defined(__AVR_ATmega1284__)\
|| defined(__AVR_ATmega644P__)\
|| defined(__AVR_ATmega644__)\
|| defined(__AVR_ATmega64__)\
|| defined(__AVR_ATmega32__)\
|| defined(__AVR_ATmega324__)\
|| defined(__AVR_ATmega16__)
// Mighty Layout
..
« Last Edit: February 25, 2013, 09:35:07 am by pito » Logged

Rapa Nui
Offline Offline
God Member
*****
Karma: 16
Posts: 881
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It seems the toggling ie. pin31 does not work (nor 14,23,24..). This works:
Code:
#include <DigitalIO.h>
// Create object for pin XX in output mode and demo toggle().
DigitalPin<31> pin31(OUTPUT);
void setup() {}
void loop() {
  // toggle is a two byte instruction that executes
  // in two cycles or 125 ns on a 16 MHz CPU
  //pin31.toggle(); // <<does not work
  //delay(250);

  pin31 = 0;   // <<<this blinks
  delay(250);
  pin31 = 1;
  delay(250);
}

The same with fastDigitalToggle(PIN)..
« Last Edit: February 25, 2013, 10:17:57 am by pito » Logged

0
Offline Offline
Edison Member
*
Karma: 28
Posts: 1077
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The 32U4 is not available in DIL40, afaik..
I am not worried about 40 pin 32U4.

If I choose the "standard layout for these:
Code:
#elif defined(__AVR_ATmega1284P__)\
|| defined(__AVR_ATmega1284__)\
|| defined(__AVR_ATmega644P__)\
|| defined(__AVR_ATmega644__)\
|| defined(__AVR_ATmega64__)\
|| defined(__AVR_ATmega32__)\
|| defined(__AVR_ATmega324__)\
|| defined(__AVR_ATmega16__)

What about SANGUINO and Bobuino boards?

I will look at the data sheet for toggle.  It may not work on this family.  It could also be a compiler problem.

The compiler must compile this way:
Code:
    // will compile to sbi and PIN register will not be read.
      *pinMap[pin].pin |= 1 << pinMap[pin].bit;
« Last Edit: February 25, 2013, 10:34:14 am by fat16lib » Logged

Rapa Nui
Offline Offline
God Member
*****
Karma: 16
Posts: 881
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
What about SANGUINO and Bobuino boards?

The pin layout and core is defined in /variants/blabla and /cores/blabla (where the board.txt points to the actual core and variant) ..

So, the best solution would be, if all libs creators will use the settings coming from those folders, somehow..  smiley-sad-blue
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 279
Posts: 15310
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am not sure what you are suggesting.  

Should I have more than one pin layout for 40-pin DIP processors?

Sangino defines the analog pins and digital pins 24 - 31 in a different order than mighty.

If so how do I know which layout to use?

With ATmega32U4 I have Leonardo and Teensy and the CORE_TEENSY symbol lets me choose the pin layout.

Edit: I looked at the three variants and don't see a #define that helps for Standard, SANGUINO, Bobuino.



Well that's why the user's hardware variants allow for unique pin mappings for different board pin out assignments even if the same avr chip is being used. For example the mighty 1284P and the Bobuino 1284P define different pins_arduino.h files to be used when their board type is selected even though they use the same avr chip. Can't your IO additions utilize the standard pin mapping that automatically gets selected when the board type is chosen?

Lefty
Logged

Rapa Nui
Offline Offline
God Member
*****
Karma: 16
Posts: 881
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

..or, to make it simple, to make your IO defs based on (boards.txt):
Code:
atmega32_11_115.build.core=mighty32
atmega32_11_115.build.variant=mighty32
Logged

0
Offline Offline
Edison Member
*
Karma: 28
Posts: 1077
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

retrolefty,
Quote
Well that's why the user's hardware variants allow for unique pin mappings for different board pin out assignments even if the same avr chip is being used. For example the mighty 1284P and the Bobuino 1284P define different pins_arduino.h files to be used when their board type is selected even though they use the same avr chip. Can't your IO additions utilize the standard pin mapping that automatically gets selected when the board type is chosen?

Lefty
No you can't generate fast bit set and bit clear instruction with the variant maps.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 279
Posts: 15310
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

retrolefty,
Quote
Well that's why the user's hardware variants allow for unique pin mappings for different board pin out assignments even if the same avr chip is being used. For example the mighty 1284P and the Bobuino 1284P define different pins_arduino.h files to be used when their board type is selected even though they use the same avr chip. Can't your IO additions utilize the standard pin mapping that automatically gets selected when the board type is chosen?

Lefty
No you can't generate fast bit set and bit clear instruction with the variant maps.

Well then I guess you will just have to decide which 1284P 'boards' you wish to support for you IO command additions, as there is no 'official' arduino standard pin out assignment for the 1284P or 644P board types, or for that matter any AVR chip that is not already used in a Arduino company produced board type.

Lefty
Logged

Rapa Nui
Offline Offline
God Member
*****
Karma: 16
Posts: 881
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Something like:
Code:
#elif defined(__variant_mighty32__) || defined(__variant_mighty64__)||  defined(__variant_mighty1284__).. etc.
// Mighty Layout
..
#elif defined(__variant_bobulino32___) || defined(__variant_bobulino64__)...
// Bobulino Layout
..
#elif defined(__variant_sanguino32___) || defined(__variant_sanguino64__)...
// Sanguino Layout
..
where the __variant_XY__ comes from actual boards.txt used:
Code:
atmega32_11_115.build.core=mighty32
atmega32_11_115.build.variant=mighty32
« Last Edit: February 25, 2013, 11:05:15 am by pito » Logged

0
Offline Offline
Edison Member
*
Karma: 28
Posts: 1077
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

pito,

I can't pursue the toggle problem since I don have hardware.  The data sheet says it should work and it seems to compile correctly:

Code:
 DigitalPin<31> pin31(1);

void toggle() {
  pin31.toggle();
}
   4:   d7 9a           sbi     0x1a, 7 ; 26
   6:   08 95           ret

Logged

0
Offline Offline
Edison Member
*
Karma: 28
Posts: 1077
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

pito,

How do symbols like __variant_mighty32__  get define?
Logged

Rapa Nui
Offline Offline
God Member
*****
Karma: 16
Posts: 881
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
How do symbols like __variant_mighty32__  get define?
From within the build environment - it is get parsed from boards.txt as it is used in the build process (in order to select cores an variants folders for the actual build)..
« Last Edit: February 25, 2013, 11:21:28 am by pito » Logged

Rapa Nui
Offline Offline
God Member
*****
Karma: 16
Posts: 881
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I can't pursue the toggle problem since I don have hardware.  The data sheet says it should work and it seems to compile correctly:
My hw (atmega32) keeps the pin level low when doing:
Code:
pinXY.toggle();
delay(250);
in a loop. It is my understanding it should have blinked..

PS: it stays at the level set with ie:
Code:
pin13.config(OUTPUT, HIGH);
« Last Edit: February 25, 2013, 11:33:27 am by pito » Logged

0
Offline Offline
Edison Member
*
Karma: 28
Posts: 1077
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

pito,

I searched all the maniacbug-mighty files and don't find the symbols.

Does this sketch print Yes?
Code:
void setup() {
  Serial.begin(9600);
#ifdef __variant_mighty32__
  Serial.println("Yes");
#else
  Serial.println("No");
#endif
}
void loop() {}
Logged

0
Offline Offline
Edison Member
*
Karma: 28
Posts: 1077
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
My hw (atmega32) keeps the pin level low when doing:
Code:

pinXY.toggle();
delay(250);

in a loop. It is my understanding it should have blinked..

It does on Uno and Mega.
Logged

Pages: 1 [2] 3   Go Up
Print
 
Jump to: