Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

version 2083
Goto page Previous  1, 2
 
Post new topic   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 282
Location: D.F.

mexico.gif
PostPosted: Thu Jul 16, 2020 6:41 am    Post subject: Reply with quote

    @Printpix52 : you have selected the SAMPLE ELECTRONICS programmer. This is the default. So my guess is that you did not made the changes to the options.
    Under Options, there is a new option : Select Settings File
    It allows to make a copy of an option file and to use that. So this way you can select your old 2082 file, and make a copy for 2083.
    It also allows to select the option file location.



Thank you very much already resolved.
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5915
Location: Holland

blank.gif
PostPosted: Thu Jul 16, 2020 9:44 am    Post subject: Reply with quote

Quote:
There is now a XTINY3216 & XTINY3217 so more to add!

that i do not understand. they are already included, right?

_________________
Mark
Back to top
View user's profile Visit poster's website
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Thu Jul 16, 2020 11:11 am    Post subject: Reply with quote

Yes they are in the dat files I must have missed them !
not 100% at the moment its not "the 19 bug" but still left my head fuzzy.
got some xtiny on order going to test them when they arrive.
Regards Paul
Back to top
View user's profile
Memen

Bascom Member



Joined: 06 May 2016
Posts: 13

blank.gif
PostPosted: Thu Jul 16, 2020 9:13 pm    Post subject: Reply with quote

Who mastered the MCS Bootloader on new chips?
Back to top
View user's profile AIM Address
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5915
Location: Holland

blank.gif
PostPosted: Thu Jul 16, 2020 9:15 pm    Post subject: Reply with quote

i did. i will make it available when i added some comment to it.
_________________
Mark
Back to top
View user's profile Visit poster's website
Memen

Bascom Member



Joined: 06 May 2016
Posts: 13

blank.gif
PostPosted: Thu Jul 16, 2020 9:20 pm    Post subject: Reply with quote

Fine! I'm waiting! I wonder how much free space remains in the 416 chip)))
Back to top
View user's profile AIM Address
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5915
Location: Holland

blank.gif
PostPosted: Thu Jul 16, 2020 9:21 pm    Post subject: Reply with quote

ok, here it is. that should get you started.
read the comment. the boot and normal space are kind of reversed.

Code:
'----------------------------------------------------------------
'                          (c) 1995-2020, MCS
'                        Bootloader-Xtiny.bas
'  This sample demonstrates how you can write your own bootloader
'  in BASCOM BASIC for the XTINY
' The xtiny has a different memory lay out
' Normal AVR starts with normal application code and the boot code is placed at the end of memory.
' XTINY starts with BOOT memory. So we always start in BOOT mode.
' With the BOOTEND fuse we can set the size of the BOOT area.
'  A value of 1 will give a size of 256 bytes, a value of 2 gives 512 bytes, etc.
'  In this example we use less than 1024 bytes so we set the fuse to 4.

' After the optional boot space there is the APPLICATION CODE
' And after the APPLICATION CODE there is the APPLICATION DATA
' When you dont want a boot loader you set the bootend fuse to 0.
'  your app will use the boot and application code
' When you want a boot loader, you determine the size of the boot loader and then
'  set the fuse to the proper size
' With a boot loader, the code simply checks if the #123 data is received.
' If so, it starts the loading. If not it continues.
' It is similar to the normal AVR boot loading. The normal AVR boot starts after the normal space.
' # There is one important difference. With normal AVR all the code start at &H0000.
'   For the loader we then use the $LOADER directive to place the code at the proper address
' For XTINY the boot loader starts at &H0000 thus is considred a normal application without specific switches
' Your normal code must now be located after the bootloader. This means you need to instruct the compiler to place the code
' at a different address. We use $ROMSTART for this purpose.
' Remember that AVR has word address. WHich means that each address uses 2 bytes of memory.
'-----------------------------------------------------------------

$regfile = "atxtiny816.dat"
$crystal = 20000000
$hwstack = 40
$swstack = 40
$framesize = 40

Config Sysclock = 20mhz , Prescale = 1
Config Com1 = 115200 , Mode = Asynchroneous , Parity = None , Databits = 8 , Stopbits = 1

Const Page_size = 64                                        'page size is 64
Const Num_pages = 128                                       'number of page is 128

'It is VERY IMPORTANT that the baud rate matches the one of the boot loader
'do not try to use buffered com since we do not use interrupts

'possible return codes of the PC bootloader.exe
' -6005    Cancel requested
' -6006    Fatal time out
' -6007    Unrecoverable event during protocol
' -6008    Too many errors during protocol
' -6009    Block sequence error in Xmodem
' -6016    Session aborted

'since this is a boot loader we do not want a vector table
'we reduce the vector table to 0
$reduceivr

'Dim the used variables
Dim Bstatus As Byte , Bretries As Byte , Bblock As Byte , Bblocklocal As Byte
Dim Bcsum1 As Byte , Bcsum2 As Byte , Buf(128) As Byte , Csum As Byte
Dim J As Byte , Wptr As Word

'Disable Interrupts                                          'we do not use ints

'We start with receiving a file. The PC must send this binary file

'some constants used in serial com
Const Cnak = &H15
Const Cack = &H06

$timeout = 400000                                           'we use a timeout
'When you get LOADER errors during the upload, increase the timeout value
'for example at 16 Mhz, use 200000

Bretries = 5                                                'we try 5 times
Do
   Bstatus = Waitkey()                                      'wait for the loader to send a byte
   Print Chr(bstatus);                                      'echo back

   If Bstatus = 123 Then                                       'did we received value 123 ?
      Goto Loader                                           'jump into boot loader
   End If
   Decr Bretries
Loop Until Bretries = 0

'if we arrive here, there was not boot character received. we simply continue
Goto Application_start_noload                               'goto the normal code


'this is the loader routine. It is a Xmodem-checksum reception routine
Loader:
   Do
      Bstatus = Waitkey()                                   ' flush the data
   Loop Until Bstatus = 0

   Bretries = 10                                            ' number of retries
   Wptr = &H8400                                            ' mapped memory uses byte address and starts at &H8000
                                                            ' we add the max size of the loader to it since that is where the normal code will be written to
   Do
      Bblocklocal = 1
      Csum = 0                                              ' checksum is 0 when we start
      Print Chr(cnak);                                      ' firt time send a nack
      Do

         Bstatus = Waitkey()                                ' wait for status byte

         Select Case Bstatus
            Case 1:                                         ' start of heading, PC is ready to send
               Csum = 1                                     ' checksum is 1
               Bblock = Waitkey() : Csum = Csum + Bblock   ' get block
               Bcsum1 = Waitkey() : Csum = Csum + Bcsum1    ' get checksum first byte
               For J = 1 To 128                             ' get 128 bytes
                  Buf(j) = Waitkey() : Csum = Csum + Buf(j)
               Next

               Bcsum2 = Waitkey()                           ' get second checksum byte
               If Bblocklocal = Bblock Then                 ' are the blocks the same?
                  If Bcsum2 = Csum Then                     ' is the checksum the same?
                     Gosub Writepages                       ' yes go write the page
                     Print Chr(cack);                       ' acknowledge
                     Incr Bblocklocal                       ' increase local block count
                  Else                                      ' no match so send nak
                     Print Chr(cnak);
                  End If
               Else
                  Print Chr(cnak);                          ' blocks do not match
               End If
            Case 4:                                              ' end of transmission , file is transmitted
            '  Waitms 100                                   ' OPTIONAL REMARK THIS IF THE DTR SIGNAL ARRIVES TO EARLY
               Print Chr(cack);                             ' send ack and ready
               Waitms 20
               Goto Application_start                       ' start new program
            Case &H18:                                      ' PC aborts transmission
               Goto Application_start                       ' ready
            Case 123 : Exit Do                              ' was probably still in the buffer
            Case Else
               Exit Do                                      ' no valid data
         End Select
      Loop
      If Bretries > 0 Then                                  ' attempte left?
         Waitms 1000
         Decr Bretries                                      ' decrease attempts
      Else
         Exit Do                                            ' reset chip
      End If
   Loop

Application_start:
   Cpu_ccp = &HD8
   Rstctrl_swrr = 1                                         ' perform a soft reset

'no code between the label above and below !

Application_start_noload:
   Nvmctrl_ctrlb.nvmctrl_bootlock_bp = 1                    ' enable boot section lock
   Goto &H200                                               ' normal app code

'this sub routine will write the pages
Writepages:
   For J = 1 To 128                                         ' get 128 bytes
      Out Wptr , Buf(j)                                     ' write to mapped memory page
      Incr Wptr                                             ' increase pointer
      If J = 64 Then                                        ' do the page write here
         Gosub Page_erase_write
      End If
   Next

   'walk into this code so the second page gets written too
Page_erase_write:
   Cpu_ccp = &H9D
   Nvmctrl_ctrla = 3                                        'Erase and write page
   Bitwait Nvmctrl_status.nvmctrl_fbusy_bp , Reset
Return

'this loader takes less than 1024 bytes so the BOOT FUSE is set to 4.
'do NOT FORGET that your normal app must use $ROMSTART=&H200 in that case  : halve of the bytes size of the loader

'one other thing : the reset pin works in UPDI mode by default. so your chip will not reset when you do not change the fuse
'but there are other ways of reset such as soft reset, bod and wd.
 


note: corrected $ROMSTART=&H200 which was wrongly $ROMSIZE

_________________
Mark


Last edited by albertsm on Tue Jul 21, 2020 12:05 pm; edited 1 time in total
Back to top
View user's profile Visit poster's website
Memen

Bascom Member



Joined: 06 May 2016
Posts: 13

blank.gif
PostPosted: Thu Jul 16, 2020 10:08 pm    Post subject: Reply with quote

Chip 416 not pulling:

Error : 22 Line : 59 Out of SRAM space [BUF] , in File : Bootloader.bas
Error : 46 Line : 112 Assignment error, unknown variable (DIM) [BUF(J): 0 WAITKEY(): 200] , in File : Bootloader.bas
Error : 93 Line : 112 Variable not dimensioned [BUF(J)] , in File : Bootloader.bas
Error : 7 Line : 112 IF THEN expected [ 112] , in File : Bootloader.bas
Error : 269 Line : 112 END SELECT expected , in File : Bootloader.bas
Back to top
View user's profile AIM Address
KenHorse

Bascom Member



Joined: 16 Jul 2004
Posts: 523

blank.gif
PostPosted: Fri Jul 17, 2020 7:00 pm    Post subject: Reply with quote

albertsm wrote:
@KenHorse : you should install into a new folder. installing over 2082 should also work but that is not tested. Installing from within bascom is tested and that works properly. Also manual installing by downloading, unzipping, and running setup was tested. Tests were done on Win7 and Win10.
You might want to try again. run bascom with admin rights so it has all rights to install and install into a new folder.


I tried installing over the top of my existing 2.0.8.2 installation directory (C:\MCS_Electronics\BASCOM-AVR) and that's what failed. I tried both the automatic update (from within Bascom) as well as the manual download and installation, both with the same error'd results.
Back to top
View user's profile
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Sun Jul 19, 2020 5:47 am    Post subject: Reply with quote

I am having a problem with byte array overlayed on to double , word ...
Should it work backwards right to left if a byte array is overlayed

Regards Paul

Code:

$regfile = "m1284pdef.dat"
$crystal = 20000000
$baud = 19200
$hwstack = 32                                               ' default use 32 for the hardware stack
$swstack = 10                                               'default use 10 for the SW stack
$framesize = 40                                             'default use 40 for the frame space

dim I as byte
Dim S As String * 4
Dim Sa(5) As Byte At S Overlay
Dim Scd As Double
Dim Sc(8) As Byte At Scd Overlay
Dim Fd As Word At Sc(1) Overlay

' scd=4251398078363129640 dont cut and paste from windows calculator! se mws below
scd=123456

Print "word overlay'"
Print Hex(fd)
Print "double "
Print Hex(scd)
Print "array elements 8 to 1"
For I = 8 To 1 Step -1
Print Hex(sc(i)) ;
Next


S = "text"
Print
For I = 1 To 5
   Print Chr(sa(i));
Next

End
 


Last edited by Paulvk on Mon Jul 20, 2020 5:54 am; edited 1 time in total
Back to top
View user's profile
Memen

Bascom Member



Joined: 06 May 2016
Posts: 13

blank.gif
PostPosted: Sun Jul 19, 2020 7:26 pm    Post subject: Reply with quote

Several questions arose about the new family.

1. How to configure a pin with a pull-up?

$regfile = "atxtiny416.dat"
Config PINB.4 = INPUT
portB.4 = 1

if PINB.4 = 1 then

Condition not met

end if

2. How to configure UART0 for alternative pins?


Last edited by Memen on Sun Jul 19, 2020 11:41 pm; edited 3 times in total
Back to top
View user's profile AIM Address
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Sun Jul 19, 2020 10:01 pm    Post subject: Reply with quote

Paulvk wrote:
Code:
Dim Scd As Double
 scd=4251398078363129640

It has nothing to do with the new version.

If you'd have some basic knowledge of doubles, mantissa, exponent and all that stuff, you'd know it's completely impossible to store a 62 bit Integer into a Double with its 52 bit mantissa.
Even numbers smaller than 52 bit may not be exactly reproduced due to quantizing errors.

It's all in the help, you only need to read it, topic 'Language Fundamentals'.

Result: '4251398078363129640' is already altered in the moment it is assigned to scd.
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5915
Location: Holland

blank.gif
PostPosted: Mon Jul 20, 2020 9:16 am    Post subject: Reply with quote

Like i wrote when i started this thread ; when there is a problem contact support with the proper info.
If you want to post here it is ok, but in the proper forum and with the right topic. do not put everything in 1 topic. Also consider who can help with the info you provide.

_________________
Mark
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum