Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

Pololu Forum

A-Star 328PB 5V, 16Mhz - PWM on Pins 0 and 1?

The pinout chart for the 328PB shows pins 0 & 1 can be used as PWM (analogWrite) although they are typically part of TTL programming. I want to use these 2 pins for fading LEDs but unless I can disable RX/TX on them it doesn’t work. How do I do that? I’m already using analogWrite on pins 2, 3, 5 & 6 so I’m out of PWM outputs unless I try pins 10 & 11 on the bottom of the board as I need a total of 6 PWM/analogWrite pins. I had a look at the datasheet but couldn’t see what I need.

Hello.

You did not say whether you are programming the A-Star 328PB via its ISP header or via the TTL serial programming header.

I would recommend using the ISP header so you do not have to worry about pins 0 and 1 being used by the bootloader and by the USB-to-serial adapter. If you do that, the AVR’s UART should be disabled by default and you do not have to do anything special to disable it.

–David

I’m programming the board via TTL using the TTL port. I have not wanted to use the ISP header as it blows away the bootloader.

Are you saying that if I program the board via the ISP header it will disable the TX/RX on those pins? Because I tried setting them both to OUTPUTs in my setup() to no avail.

The USART, which provides TX and RX functionality, is disabled by default. However, the serial bootloader that we provide for the A-Star 328PB enables it in some circumstances before your program runs. If you program using the ISP interface, you would erase the bootloader, meaning that the USART would always be disabled by default.

If you want to use the bootloader instead of ISP, you should be able to disable the USART at the beginning of your program with this line of C/C++ code:

UCSR0B = 0;

–David

Excellent, thanks so much David!