Go Down

Topic: Need some help on ATMEGA32U4 pins mapped to Arduino micro (Read 6826 times) previous topic - next topic

liuzengqiang

I just got an Arduino micro clone and want to know the pin mapping from ATMEGA32U4 to Arduino pins. Ultimately I want to make my own board using the ATMEGA32U4. Here is a pin correspondence I made:



I read from Doc7766 that there are 26 GPIO lines on this chip. I only counted 24 pins have been assigned various Arduino pin names. (Oops, forgot to increment D24 to D28 but no worries they are duplicates)

I also listed the two pins that are not mapped into Arduino pins, PD5 and PE2. I know PE2 has special function to enable bootloader at reset. So I'm not going to mess with this pin. But what about PD5 that is used to simply turn on/off a TX led, which is CTX_bar pin. I wonder if there is any easy way to give this pin an Arduino pin name and not use the extended USART mode. Maybe not worth the trouble just for one pin.

What about SS/RXLED? Am I able to use this pin to do chip select for an SD card or is it not able to do it due to some arduino set up? I really want to use this pin. I'm short on pins for the project. Thanks.
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

Riva

I think the ATMega32U4 is same as Leonardo so does this help?
Don't PM me for help as I will ignore it.

liuzengqiang

I found this after reading through official page:

Quote
RX_LED/SS This is an additional pin with respect to the Leonardo. It is connected to the RX_LED that indicates the activity of transmission during USB communication, but is can also used as slave select pin (SS) in SPI communication.


I don't understand. If I do some USB communication such as sending some text to a PC, then this pin will be toggled. Then the SPI device may not like it. Can I disable its USB activity indication?

Riva,

Thanks. I didn't know this page. I kind of read the doc7755 in conjunction with EAGLE design files of leo and micro. It doesn't explain whether I can use the SS pin to really select a slave. Please see above.
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

Riva


Thanks. I didn't know this page. I kind of read the doc7755 in conjunction with EAGLE design files of leo and micro. It doesn't explain whether I can use the SS pin to really select a slave. Please see above.

Looking at the schematic and it looks like the PB0 (SS) pin sinks the RX LED so if it's set to output to act as SS master it will work fine. Not sure what would happen if it's left as input for SS slave and you used RX.
Don't PM me for help as I will ignore it.

liuzengqiang


Not sure what would happen if it's left as input for SS slave and you used RX.


Exactly. I did my best reading the hardware serial class code. I couldn't understand what happens.
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

Riva



Not sure what would happen if it's left as input for SS slave and you used RX.

Exactly. I did my best reading the hardware serial class code. I couldn't understand what happens.

pins_arduino.h for Leonardo define...
Code: [Select]
#define TX_RX_LED_INIT DDRD |= (1<<5), DDRB |= (1<<0)
#define TXLED0 PORTD |= (1<<5)
#define TXLED1 PORTD &= ~(1<<5)
#define RXLED0 PORTB |= (1<<0)
#define RXLED1 PORTB &= ~(1<<0)

and USBCore.ccp define...
Code: [Select]
RXLED1; // light the RX LED
RxLEDPulse = TX_RX_LED_PULSE_MS;

Are you using SPI in slave mode then because if it's master mode the LED's should be irrelevant. You may need to remove the LED flicker code from USBCore if your expecting to receive serial data and be SPI slave at the same time.
Don't PM me for help as I will ignore it.

liuzengqiang

Riva,

Thank you very much for providing the information. It helped greatly! I am planning to use SPI master mode to control an SD card with the SS pin. I also plan to use the USB TTL port for input and output. I need both. Excuse my ignorance. I can understand limited amount of register operations . Please give me some critic on my understanding:

1. TX_RX_LED_INIT makes PORTD5 and PORTB0 output pins.
2. TXLED0 and TXLED1 manipulates PORTD5 values go 0 and 1, so do RXLED0 and RXLED1 manipulate PROTB0.
3. In order to disable the features and use these pins as normal pins, I should probably #define TX_RX_LED_INIT NOP or {;} or something? What do you advise?
4. To use this TXLED pin (PORTD5) in Arduino, I add to digital_pin_to_port_PGM[] a line
Code: [Select]
PD, // D30 - PD5
I also add to digital_pin_to_bit_mask_PGM[] a line
Code: [Select]
_BV(5), // D30 - PD5


The above makes it pin 30 in Arduino.
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

Riva

Sorry I have reached the limit of my understanding of Leonardo. I assume using SPI and UART should not be a problem as the Ethernet shield must use the SS pin. Maybe someone else can give you more details on how to re-define the LED #defines and add the TXLED pin if they are needed.
Don't PM me for help as I will ignore it.

liuzengqiang

Ethernet shield uses pin 4 and 10 for ethernet controller and sd card, not ss. Thank you for helping!
Serial LCD keypad panel,phi_prompt user interface library,SDI-12 USB Adapter

Go Up