light_ws2812 icon indicating copy to clipboard operation
light_ws2812 copied to clipboard

Trying Xmega ATXMEGA128A1

Open rselec opened this issue 5 years ago • 2 comments

Hi, I really need to have a WS2812 lib for XMEGA, so I tried compiling for XMEGA, several issues:

First the defines for DDR and PORT will not work for Xmegas https://github.com/cpldcpu/light_ws2812/blob/68c165724458cea1ee0f257ab6627013b163d684/light_ws2812_AVR/Light_WS2812/light_ws2812.h#L94 https://github.com/cpldcpu/light_ws2812/blob/68c165724458cea1ee0f257ab6627013b163d684/light_ws2812_AVR/Light_WS2812/light_ws2812.h#L95

You need to specify something like: #define ws2812_PORTREG PORTB_OUT #define ws2812_DDRREG PORTB_DIR

But after that it won't even compile:

impossible constraint in 'asm' ...\light_ws2812.c 119 asm operand 2 probably doesn't match constraints ...\light_ws2812.c 119

I think it has something todo with: https://github.com/cpldcpu/light_ws2812/blob/68c165724458cea1ee0f257ab6627013b163d684/light_ws2812_AVR/Light_WS2812/light_ws2812.c#L176 _SFR_IO_ADDR(ws2812_PORTREG) will not result in an 6-bit positive constant, it is 0x0624 (=1572) which can't fit. I tried several other constraints but I don't have any clue which one could deal with the register address of the XMEGA PORTB_OUT register and wether the assembler code is compatible.

Please help!

rselec avatar Oct 13 '19 17:10 rselec

Yes, that is a general issue with XMEGA. I probably should add it to the faq.

Two possible solutions:

  1. Map the port you use to the lower I/O region.
  2. Use the arduino version, which is using ST to write to ports and is not limited to the lowest 64 bytes.

cpldcpu avatar Dec 03 '19 06:12 cpldcpu

Hey, I know this is a late answer, but maybe you still will find it useful. I am using AVR128DB48 and had exactly the same issue. However, I have found that there are also VPORTB_OUT and VPORTB_DIR addresses defined.

They work for simple LED blink and the ws2812 code compiles when you use them. Still did not get the ws2812 LED to work, but I am pretty sure this is a good direction :)

Jakub-Plan-d-k avatar Jun 19 '22 21:06 Jakub-Plan-d-k

Version 2.5 should fix this issue.

cpldcpu avatar Nov 18 '23 22:11 cpldcpu