You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Development Platform or Board.
All issues (building, uploading, adding new boards, etc.) related to PlatformIO development platforms
should be reported to appropriate repository related to your hardware https://github.com/topics/platformio-platform
Configuration
Operating system:
Windows ATmega development using vscode and platformio extension.
PlatformIO Version (platformio --version):
3.3.4
Description of problem
Using board = ATmega328PB in platformio.ini causes incorrect linkage to USART_UDRE_vect.
All compiles ok but gives warning that USART_UDRE_vect is misspelt. When running program on a ATmega328PB the interrupt handler misbehaves. Using board = ATmega328P in platformio.ini all works fine.
Steps to Reproduce
Create an AVR project.
Copy the platformio.ini file and cpp code below.
Build, upload and run.
Actual Results
There will be a series of blinks shown on the LED but no long blinks.
Expected Results
Thre should be two long blinks after the short ones.
If problems with PlatformIO Build System:
The content of platformio.ini:
Insert here...
; PlatformIO Project Configuration File;; Build options: build flags, source filter; Upload options: custom upload port, speed and extra flags; Library options: dependencies, extra library storages; Advanced options: extra scripting;; Please visit documentation for the other options and examples; https://docs.platformio.org/page/projectconf.html[env:ATmega328PB]platform = atmelavr
board = ATmega328PB
board_build.f_cpu = 16000000L
platform_packages = platformio/tool-avrdude@^1.70200.0
build_type = debug
upload_protocol = custom
upload_port = usb
upload_flags =
-C
${platformio.packages_dir}/tool-avrdude/avrdude.conf
-p
ATmega328PB
-P
usb
-c
avrisp2
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i
Source file to reproduce issue:
#include<string.h>
#include<util/atomic.h>// The ring buffer://
#defineRING_BUFFER_SIZE256classDRing
{
protected:uint8_t m_au08Buffer[RING_BUFFER_SIZE];
volatileuint8_t m_u08Head;
volatileuint8_t m_u08Tail;
volatileuint16_t m_u16Length;
public:DRing():
m_u08Head(0),
m_u08Tail(0),
m_u16Length(0)
{
}
boolPushISR(uint8_t u08Byte)
{
if (m_u16Length >= RING_BUFFER_SIZE)
returnfalse;
m_au08Buffer[m_u08Head++] = u08Byte;
++m_u16Length;
returntrue;
}
boolPushISR(constuint8_t *pu08Bytes, uint8_t u08Length)
{
if (m_u16Length + u08Length > RING_BUFFER_SIZE)
returnfalse;
while (u08Length > 0)
{
m_au08Buffer[m_u08Head++] = *pu08Bytes++;
++m_u16Length;
--u08Length;
}
returntrue;
}
boolPullISR(uint8_t &ru08Byte)
{
if (m_u16Length == 0)
returnfalse;
ru08Byte = m_au08Buffer[m_u08Tail++];
--m_u16Length;
returntrue;
}
};
static DRing s_TxRing;
// Blinks the LED for debug.//
#defineLED_DDR DDRB
#defineLED_PORT PORTB
#defineLED_BIT5// D13 (LED)staticuint16_t s_u16NumBlinks;
// Good for upto 2s.//staticvoiddelayMS(uint32_t ms)
{
uint32_t count = (F_CPU / 1000 * ms) / 12;
for (uint32_t u = 0; u < count; ++u)
__asm__volatile("nop\n\t");
}
voiddot()
{
++s_u16NumBlinks;
for (uint16_t u = 0; u < s_u16NumBlinks; ++u)
{
LED_PORT |= 1 << LED_BIT;
delayMS(250);
LED_PORT &= ~(1 << LED_BIT);
delayMS(250);
}
delayMS(2000);
}
voiddash()
{
LED_PORT |= 1 << LED_BIT;
delayMS(1000);
LED_PORT &= ~(1 << LED_BIT);
delayMS(2000);
s_u16NumBlinks = 0;
}
// The serial stuff://
#defineDDR DDRD
#defineTX_BIT1
#defineBAUDRATE57600UL// Called when the UART is ready to transmit the next byte.//ISR(USART_UDRE_vect, ISR_BLOCK)
{
// These won't he seen.//dash();
dash();
uint8_t byte;
if (!s_TxRing.PullISR(byte))
{
// Disable this interrupt.//
UCSR0B &= ~_BV(UDRIE0);
}
else
{
// Start transmission//
UDR0 = byte;
}
}
staticvoidsetBaud()
{
uint16_t UBRR_VAL = (unsignedint)(F_CPU / (16.0 * BAUDRATE) + 0.5) - 1;
uint16_t UBRR_VAL_U2X = (unsignedint)(F_CPU / (8.0 * BAUDRATE) + 0.5) - 1;
double BAUD = F_CPU / (16 * (UBRR_VAL + 1));
double BAUD_U2X = F_CPU / (8 * (UBRR_VAL_U2X + 1));
double ERROR = (BAUD / BAUDRATE) - 1;
double ERROR_U2X = (BAUD_U2X / BAUDRATE) - 1;
if (ERROR < 0)
ERROR *= -1.0;
if (ERROR_U2X < 0)
ERROR_U2X *= -1.0;
if (ERROR <= ERROR_U2X)
{
UCSR0A &= ~_BV(U2X0);
UBRR0 = UBRR_VAL;
}
else
{
UCSR0A |= _BV(U2X0);
UBRR0 = UBRR_VAL_U2X;
}
}
staticvoidputBytes(constuint8_t *pu08Data, uint8_t u08DataLen)
{
dot();
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
if (!s_TxRing.PushISR(pu08Data, u08DataLen))
return;
// Enable the transmit buffer empty interrupt.//
UCSR0B |= _BV(UDRIE0);
// See if transmit buffer is empty.//if ((UCSR0A & _BV(UDRE0)) == _BV(UDRE0))
{
uint8_t byte;
if (s_TxRing.PullISR(byte))
{
// The first byte will be sent ok as it isn't done by the interrrupt function.//
UDR0 = byte;
dot();
}
}
// *** This will allow interrupts. ***//dot();
}
dot();
// At this point there should be dot, dot, dot, dot but there won't be.
}
voidInit()
{
// Enable USART transmitter.//
UCSR0B = _BV(TXEN0);
// Set frame format: asynchronous, 8 data bits, no parity, 1 stop bit//
UCSR0C = _BV(UCSZ01) | _BV(UCSZ00);
// Do this after UCSRC is set above.//setBaud();
// Set data direction: 0 for i/p, 1 for o/p.//
DDR |= _BV(TX_BIT);
}
voidWrite(constchar *pszStr)
{
if (pszStr == 0 || *pszStr == 0)
return;
int len = strlen(pszStr);
putBytes((constuint8_t *)pszStr, len);
}
intmain()
{
LED_DDR |= 1 << LED_BIT;
Init();
sei();
Write("KilnDAC\r\n");
while (true)
{
}
}```
### Additional info
The text was updated successfully, but these errors were encountered:
What kind of issue is this?
All issues (building, uploading, adding new boards, etc.) related to PlatformIO development platforms
should be reported to appropriate repository related to your hardware
https://github.com/topics/platformio-platform
Configuration
Operating system:
Windows ATmega development using vscode and platformio extension.
PlatformIO Version (
platformio --version
):3.3.4
Description of problem
Using board = ATmega328PB in platformio.ini causes incorrect linkage to USART_UDRE_vect.
All compiles ok but gives warning that USART_UDRE_vect is misspelt. When running program on a ATmega328PB the interrupt handler misbehaves. Using board = ATmega328P in platformio.ini all works fine.
Steps to Reproduce
Actual Results
There will be a series of blinks shown on the LED but no long blinks.
Expected Results
Thre should be two long blinks after the short ones.
If problems with PlatformIO Build System:
The content of
platformio.ini
:Source file to reproduce issue:
The text was updated successfully, but these errors were encountered: