Very new chip by Microchip(Atmel) ATmega4809 has a very unique CPLD like logic and also promised to be applied to next Arduino, why not try!
Nowadays, Atmel is a part of Microchip and some technology is transferred into ATmega chips. (I am not sure which Microchip or Atmel is the original one but..) Configurable Custom Logic (CCL) is one of novelty technique for AVR (PIC's has the name "Configurable Logic Cell", why don't they put same name for same "Microchip"??)
CCL is a kind of tiny programmable logic with look-up-table, same as FPGA or CPLD. Here I would like to show you how to use it through Atmel Studio.
One notice before jumping into the body explanation is,
Let' get started!!
Let start on AtmelStudio selecting "Atmel Start Project"
And click "CREAT NEW PROJECT"
In the window, just put "4809" for search term and select "ATmega4809-AFR" and click "CREATE NEW PROJECT"
Now the project is fully empty and let click "Add software component"
Just input "CCL" for search term and click "Add component(s)"
Now your project will grow up with "Digital_Glue_logic_0".
Let' just click "CCL" on the left side of the window.
Now the time to connect it. I/O pins of CCL are limited PA0, 1, 2, and PC0, 1, 2. Now the board has accessible pins of PC0, 1, 2 and let make it as input and output as PC3. (You can define as you wish, within the limitation..) Don't forget to activate "LUT1" by check box on.
And click and select LUT1 box and make it as simple AND.
Now let's configure pin status by "PINMUX". Already PC0, 1, 2 are set as input and PC3 as output.
Let activate internal pull-up for input and set the initial state of output (PC3) as low.
It's done! And let's click "GENERATE PROJECT"
Window will appear and let's name it as you wish.
And now all the required source should be set up. Let's check "main.c"
MCU does nothing for the job. Just initialize MCU, and over.
Now, let "rebuild solution"
Since it is empty, so you sit see "Data Memory Usage" 0bytes!!
Exactly the same as the general program. Binary can be uploaded through UPDI.
Now it's done! Switching input level will show the logic level as defined!! ATmega4809 is now working as "single AND"!
I made several experimental board (may be delivered on my tindie store) and here I would like to explain how to start project with this board on Atmel Studio with Atmel ICE.
First of all, we need to install Atmel Studio (if not yet) and connect it to the onboard UPDI connector. The board is USB bus power so we need additional USB cable connection from your PC to the board.
UPDI connector has a right direction so please follow the onboard guideline.
Now let's start Atmel Studio and select "Atmel Start Example Project"
and click "Browse Examples"
Just entering "4809" as the search word, you will find 4 examples. (still not so much, indeed.)
Now let's select the first "ADC Basics with megaAVR 0-Series" and click "Open Selected Example"
You will see this example uses three blocks, VREF_0, ADC_0, and USART_0. Now let's click "ADC_0" and see which pin is used for.
In the bottom of window, you will see the current setup for the example program. The PD6 is selected as ADC input. PD6 is "AN" of mikroBUS pinout, and it's ok for the check.
And let's switch to USART_0 setting.
The USB-USART interface (CP2102) of "4809 Explorer board" has a connection with PA0 and PA1 so let's switch to..
RXD to PA1 and TXD to PA0.
Now the online preparation is finished. Let's click "Generate Project"!!
You will see the Atmel start importer windows and please name your new project name as you wish, and after clock "OK" you will see the
Downloaded files in the solution explorer. The files in src directory are prepared for the definition of above (like USART settings..)
Now the source files are prepared (no need of modification) so let's select "Rebuild Solution"
Currently the files are "as is" so it will not produce any error.
Now let's start binary uploading to the 4809 explorer...
You will see the device programming window, and let's select Tool as "Atmel-ICE" and device "ATmega4809" and select UPDI as interface and click "Apply"
After setting UPDI clock as default 100kHz by click "Set" in the bottom-right button, let's read device signature. If it presents "0x1E9651", then the connection is succeeded.
Now the time for uploading. Select "Memories" and just click "Program" will flash your board with the new binary!
This sample program will read ADC and will output to USART, so just read USART with serial console, you will see the value of PD6(AN) pin voltage of onboard connector.
In the very the same manner, the sample with OLED display can be made by "ATmega4809 RTOS Example". Let's try!
Here we can see the operation of the board. Every three version requires Atmel ICE for UPDI binary uploading. But by googling by the word "UPDI", I've found several implementation by various ways (one of them are on Arduino sketch, Mega328P is working as a converter from serial to UPDI !, great). I thought, the forthcoming next Arduino will be implemented by the same way as conventional Mega328P (like DTR-RST connection through capacitor), but I can add one prediction, 32U4 or something with USB and it may talk with 4809 via UPDI...
By the way, I have a naive question
Why Microchip still release new chip by "Atmel" logo? Atmel logo will remain?
Actually I have already several "not released" prototyping board. The first one (left of the above) is simple board with 3.3V LDO and 3-tact switch and MikroBus interface. The power is applied through "barrel" connector. The binary is uploaded through UPDI, indeed single wire, interface through Atmel ICE. At this stage, I noticed the importance of USB-UART interface and evolved to the next stage (mid of the above picture). It is pleasantly and comfortably working for checking and testing. But I am "OLED lover". Also the sample program on RTOS delivered by Microchip supports OLED display so the board has the evolution for checking it! (the right of the above picture).
The OLED is connected through SPI with ATmega4809 and as same as previous two version, still binary uploading needs the help of Atmel ICE. But I hope (may be not ?) Arduino.cc will make bootloader supporting UART binary uploading and the DTR of CP2102 is connected to RST of ATmega4809 through 0.1uF capacitor, believing AVR traditional.
If you want to make board with ATmega4809, please use my Eagle library of ATmega4809. The file name of it is "microwavemont_ATMega4809.lbr" will be found in the above link.
It's no worth to imitate this but the circuit is like above. All of the pin has a pin-out or connected to certain devices. In the circuit you will see UPDI 6-pin interface. YES, it is really single pin connection, even without RESET....
Device recognition is as shown above. As a proof of AVR, it has Fuse bit!, but indeed ATmega4809 is more similar to ATXmega, not general AVR like Mega328 or Tiny series in the programming manner. (You will see if you touch this chip., like DDRB is not accepted by ATMega4809 but PORTB.DIRSET)..
Here is quick comparison between:
Actually I have no experience of Xmega, but enjoying ATmega4809 needs several knowledge of Xmega, not well-known simple AVR..