View previous topic :: View next topic |
Author |
Message |
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Fri Dec 24, 2021 9:01 pm Post subject: BasCom-AVR and AVR128DB28 |
|
|
BasCom-AVR and AVR128DB28
BasCom-AVR is the BASCIC compiler for the AVR. The AVR was originally made by ATMEL and now owned by Microchip.
There are many different AVR processors. The oldest we(MCS) name ‘normal AVR’. They came in different casings. Almost all of them have a DIP/DIL variant which is ideal for quick prototyping on a breadboard.
Many processors were introduced; some with CAN, RF, USB, etc. Almost all worked up to 5V.
The Xmega processors was introduced long time ago and it used 3V3. There is not a single Xmega processor with DIP casing. So less perfect for hobbyists.
Of course converter boards are made by different companies. Xmega has DMA, casings up to 100 pins. And a speed up to 32 MHz.
The Xmega is a complete different processor compared to the normal AVR. To support them with one framework was a lot of work. The Xmega also has a different programming interface (PDI). Support does not only mean to write software and help, but also to handle support questions.
Some years ago Microchip(new owner of Atmel) began introducing new processor families. The tiny3216 for example.
Now these processors share the same name as other available tiny processors but they are completely different.
They share the AVR instruction set but that is it. A new programming interface is used named UPDI. This is a simple serial program protocol which uses just 1 pin. Some processors with little pins share the UPDI pin with another pin. But most processors have a dedicated UPDI pin.
These new tiny processors were named XTINY by MCS. Just to make a difference.
Support for the Xtiny platform comes as add on. This means you need a license in order to compile code for the Xtiny. This license is available from the MCS webshop and is linked to your BasCom-AVR serial number.
After the Xtiny the ATmega4809 and other new mega’s were introduced and supported by MCS. At the moment of writing only the mega4808 and mega4809 are supported.
The same xtiny license is required. We refer to the new mega’s as MegaX which is different than Xmega !
Again this is done to make a difference. When you are used to mega8515 for example, you will notice that mx4809 is something different than mega4809.
After the new mega there are also the DB, DA and DD series. Of those, the DB is supported first with the 128DB28 (and some other DB processors) by BasCom.
Now the DB series is like the megaX big brother/sister. And we named them AVRX.
When you sort the processors in capability/speed you get : AVR tiny, AVR mega, Xtiny, MegaX, AVRX, and finally Xmega.
The DB series has MVIO (multi voltage I/O) which means that one port can run on a different voltage domain.
The DB series also supports voltage up to 5V. And the good news is that there is a DIP version.
The DB series naming convention has improved. 128DB28 means: 128KB of flash with 28 pins casing.
The same xtiny add on is required to program the DB series. The DB series is supported by version 2085 and up.
So a first step is to get version 2085 installed
A second step is to have the license installed
In the help you will find some important topics:
- Chips, XTINY
- Chips, ATMEGAX
- Chips, AVRX
- BASCOM-IDE, Options Programmer, Supported Programmers, UPDI Programmer
While we test the 128DB28 here, we advise to start the reading with Xtiny. Then continue with ATMEGAX and finally read the AVRX help.
You will find information about the processor but also about new hardware.
It will be great to read the PDF but it is not required for the first introduction.
What is important is to know that you need an UPDI programmer. It is built into BasCom-IDE and you need just a serial port on TTL level. In the help you will find info on how to connect. Since the UPDI protocol uses 1 line, a resistor is added between the RX and TX pins. When UPDI sends it is an output and it is never a good idea to connect 2 outputs together. Thus a 1K resistor is connected between the UPDI and the TX pins.
The help will also show a circuit with a multiplexer. This will make it easy to program and use the serial port for normal use.
In this introduction we use an USB-Serial converter module.
There are many models. So check the pins! In order to program we only need the GND, TX and RX pins. We can also power our processor from the USB module. Use 3v3 or 5V. Take care not to draw too much current from the USB module. So connecting LCD modules with backlight is not a good idea.
To demonstrate we use a simple breadboard.
You can see the module is plugged into the BB. The processor requires proper decoupling of the VCC pins. This different from Xtiny, MegaX to AVRX. The DB series requires a 1uF parallel with a 100 nF capacitor to ALL VCC pins. The MVIO also requires this. Normally it is best practice to keep wires short and put capacitors between the VCC/GND pins. Since that would make the picture less clear we put the caps on the power rails of the BB. But remember when you create a PCB that the caps goes close to VDD/GND as is physically possible. All other components placement matter less.
The RED lines are the 5V VCC and are sourced from the USB module.
On the left you see the 1K resistor for the UPDI programmer. And on the right there is a simple LED and a resistor as well. The resistor can be in range from 470-1K.
Now we need a simple test program. Since the anode of the LED is connected to VCC via the series resistor and the cathode is connected to PORTD.7 we can turn it on when we make port D.7 zero. It will go off when we make the port one. By default a port will be 0 when we configure it as an output. So once programmer, at a reset the LED will turn on.
Our simply program requires the name of the processor DAT file. And we also provide the clock speed and stack size. The CONFIG OSC selects the oscillator speed. We can only enable the oscillator, we can not turn it off. We also need the CONFIG SYSCLOK which selected which oscillator is used by the processor. We use the INTERNAL oscillator, and we chose a prescale value of 1. Note that $crystal and the oscillator options must match to get the proper timing.
We configure portD.7 to be an output and in a simple loop we toggle the port pin and then wait 1 second.
Code: |
$regfile = "AVRX128db28.dat"
$crystal = 24000000
$hwstack = 40
$swstack = 40
$framesize = 40
'The AVRX series have more oscillator options
Config Osc = Enabled , Frequency = 24mhz
'set the system clock and prescaler
Config Sysclock = Int_osc , Prescale = 1
Config Portd.7 = Output
Do
Toggle Portd.7
Waitms 1000
Loop
|
We save the file and then press F7 to compile
In BasCom we select the UPDI programmer
The screen shot shows COM2, you need to adjust for the COM port you use.
You can either use F4 for an automatic flash, or select manual program to get the UPDI programmer window
Click Identify to check if there is communication:
When there is communication the processor will be identified. Press F4 to program the processor.
The baud can be changed from 115200 to 225000 . After the programming the LED should toggle with 1 second intervals.
(BASCOM-AVR version : 2.0.8.5 ) _________________ Mark |
|
Back to top |
|
|
EDC
Joined: 26 Mar 2014 Posts: 971
|
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Sat Dec 25, 2021 1:04 pm Post subject: |
|
|
good to hear someone uses it.
will add it to the help. _________________ Mark |
|
Back to top |
|
|
plouf
Joined: 19 Jan 2012 Posts: 78 Location: Athens,Greece
|
Posted: Sat Dec 25, 2021 7:43 pm Post subject: |
|
|
if we know we will use it more .. ALL compiler directives for programmer/fuse etc and ANY other are really usefull !! |
|
Back to top |
|
|
EDC
Joined: 26 Mar 2014 Posts: 971
|
Posted: Sat Dec 25, 2021 8:04 pm Post subject: |
|
|
I dont want to be offtopic.
I use $programmer when Im working on two uC at the same time. For example Xmega as a master for some other AVR. Then $programmer is my fav option
Two codes can be maintained and quick uploaded without chainging prog options. |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Sat Dec 25, 2021 9:20 pm Post subject: |
|
|
ok, i thought about extending with some other params. like com port or so. and instead of the number using a constant. this because some programmers will be removed in a future update. i get back to that later. _________________ Mark |
|
Back to top |
|
|
aphawk
Joined: 23 Jan 2010 Posts: 168 Location: Brazil
|
Posted: Sun Dec 26, 2021 6:10 pm Post subject: |
|
|
Albert,
Thanks for show us one practical example!
Believe me, your single post had cleared a lot of questions and doubts I had … and your example to program it with a simple USB to Serial adapter was excellent!
There are many new resources with this family, but maybe most of us can’t understand how to use them …
I’m reading the datasheets to understand how these timers TCA , TCB and TCD can be used , for example, to make waveforms, and really I don’t understand.
The Amp Ops must be programmed too, and cant’t find some examples, like use them as zero cross detection.
Maybe we, normal home users, need more examples for each new resources, like in the beginning of Bascom, there was plenty of code examples with comments that made simple use them.
To make things worst to me, I can’t find any AVR DB family to buy in Brasil.
I see that this family will be replacing the Atmega quickly, with a lot more resources and lower price, them I will try a lot to understand and use them.
Paulo |
|
Back to top |
|
|
hgrueneis
Joined: 04 Apr 2009 Posts: 902 Location: A-4786 Brunnenthal
|
Posted: Mon Dec 27, 2021 6:21 pm Post subject: |
|
|
I tried to order AVR128DB28 from several well known companies, but Business only!
Finally I ordered from Digikey in the USA. High charge for shipping, but at least I can get some in Dip format
for testing, before I use them on a printed board.
I like the AVR128db-series and I will get the extension for it from Bascom as soon as I get the chips.
Thanks to Mark Alberts for his work.
Best regards
Hubert |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Mon Dec 27, 2021 6:46 pm Post subject: |
|
|
hi Hubert
9 dispo tme.eu
jp _________________ pleasure to learn, to teach, to create |
|
Back to top |
|
|
hgrueneis
Joined: 04 Apr 2009 Posts: 902 Location: A-4786 Brunnenthal
|
Posted: Mon Dec 27, 2021 8:33 pm Post subject: |
|
|
JP
Thank you for the link. 13 Euro cheaper delivery.
Have a great and healthy 2022.
Best regards
Hubert |
|
Back to top |
|
|
hgrueneis
Joined: 04 Apr 2009 Posts: 902 Location: A-4786 Brunnenthal
|
Posted: Wed Dec 29, 2021 10:51 pm Post subject: |
|
|
JP
ordered at the same time (only 15 minutes apart)... both DIGIKEY from USA and TME sent from Poland came on the same shipment today.
Only difference, TME was 13 Euro cheaper in shipping charges!
Now I have four chips to experiment with.
Thanks again JP
Best regards
Hubert |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Fri Dec 31, 2021 10:16 am Post subject: |
|
|
Thanks Hubert I'm happy to help , I think this is a good way to use the forum.
Mark, can I give you a suggestion? I see a lot of comments about the AVR128DB28, We are discovering this circuit with enthusiasm. But the comments are all over the forum. It would be nice to open a specialized index
and now I'm closing my computer until next year
happy new year to all! thanks for your help during 2021
JP _________________ pleasure to learn, to teach, to create |
|
Back to top |
|
|
matjazs
Joined: 08 Nov 2016 Posts: 86
|
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Tue Mar 22, 2022 10:01 pm Post subject: |
|
|
time out can be 50. when time out is too high you might get problems.
and you can increase baud to 225000
i tested on both 3v3 and 5V without problems.
dont know what board you have.
just make sure vcc/gnd have the proper caps as shown in the datasheet.
the speed is indeed low compared to pdi. dont get that either. but.. DB series should be able to accept higher baud. just did not test/implement that. it did not work for xtiny and xmega.
you can also try x-lab from microchip and one of their programmers. i suppose it should work faster but i did not test that.
you also might try at 5V (if the rest of the board allows). _________________ Mark |
|
Back to top |
|
|
matjazs
Joined: 08 Nov 2016 Posts: 86
|
Posted: Wed Mar 23, 2022 11:57 am Post subject: |
|
|
Thanks Mark.
It works much better now. |
|
Back to top |
|
|
|