Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Problem USBASP Win7-64 Bit and BascomAVR

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
dl7sep

Bascom Member



Joined: 26 Feb 2006
Posts: 81

germany.gif
PostPosted: Tue Apr 14, 2015 6:11 pm    Post subject: Problem USBASP Win7-64 Bit and BascomAVR Reply with quote

I have changed my Computersystem to Win7-64 Bit.

BascomAVR run without a problem, only the USBASP programmers have a problem to
programming the device. When i do the programming step 2-3 times runs ok, then
1 time i get an error, then 3 times ok and so on.
The device is at 16MHz crystal clock, and i have tested different USBASP clockfrequency,
but the result is always the same.


I have tested many of libusb, filterdriver, but the windows system show me no problems.

If i have a external tool like Khazama AVR Programmer, then everything works as intended.

The original AVRISP MKII from Atmel run stable, but i have many of the cheep USBASP programmers,
and i can not believe that this will not work with bascom.

Many thanks,

Josef

(BASCOM-AVR version : 2.0.7.8 )
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 6198
Location: Holland

blank.gif
PostPosted: Tue Apr 14, 2015 7:48 pm    Post subject: Reply with quote

it works for me and i use 64 bit too.
my usbasp model might differ.
support for usbasp is written long time ago. possibly the firmware has changed and it need an update. but i can guess or believe what i want it will not help much

you create a topic but i do not see any question? what do you expect? now you are not unique and i do not blame you but in order to use my time more efficient i have a request :

@everyone : when creating a topic, there should be :
- a good description of the problem
- info about used processor and hardware
- info about used version
- details about used settings : which value does the usb time out have? which firmware of usbasp is used? and which model (there are 1001 different usbasp)
- include some zipped project with steps on how to reproduce the problem

without good info i will move topics to bascom old version, a forum i usually ignore because i only support the latest version.

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

Bascom Member



Joined: 26 Feb 2006
Posts: 81

germany.gif
PostPosted: Tue Apr 14, 2015 9:09 pm    Post subject: Reply with quote

Hello Mark,

sorry so if I rob your precious time with this problem.
Quote:
you create a topic but i do not see any question?

The question is, have any other user the same problem?
Quote:
what do you expect?

I want to use the USBASP programmer with Bascom too.
Quote:
- a good description of the problem

I cold not give more describtion, but when it is not enough, then ask me
Quote:
- info about used processor and hardware

Prozessor i have tested with this Problem (all with 16 MHz Clock) Atmega8, Atmega16, Atmega32, Atmega328P, Atmega128
Hardware:
http://www.fischl.de/usbasp/ and cheep programmers from ebay with ATmega8 Chip, but on all the latest Software from Thomas Fischl
Quote:
- info about used version

I have the latest version, and it is visible with your checkbox in the end of the question
Quote:
- details about used settings : which value does the usb time out have?

please see the attachment, i don't can see a value for usbtime, but the connector is usb2.0
Quote:
- include some zipped project with steps on how to reproduce the problem

please see the attachment for the error message, it is independent which file i was download on the prozessor
Quote:
without good info i will move topics to bascom old version, a forum i usually ignore because i only support the latest version.

It is your decision to move this topic on old version, for me it is a new problem, but i can solve this with the orignal AVRISP MKII programmer from
Atmel.

I beg your pardon, should not be a personal attack, BascomAVR is for me the best environment, to work with atmel processors.


Regards Josef
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 6198
Location: Holland

blank.gif
PostPosted: Tue Apr 14, 2015 9:33 pm    Post subject: Reply with quote

Quote:
It is your decision to move this topic on old version, for me it is a new problem, but i can solve this with the orignal AVRISP MKII programmer from
Atmel.
I beg your pardon, should not be a personal attack, BascomAVR is for me the best environment, to work with atmel processors.


I wrote to @everyone ! So it was not specific addressed to you. It is the result of lot of topics which miss important info.
I only used your topic to address this. If i wanted to ignore i would have moved it without asking questions.
It was maybe not a good idea to put this in your topic but the sticky post request are not really read Wink
So please do not take this as an attack.

The first lines were addressed to you, and there i asked what this topic is about since there was no question.

- You can try to use a lower clock. if that does not solve it :
- upload a zip file with a project. this could be some garbage bin file if you do not want to share a real project. just make sure there is a matching bas file with the same name, does not need to have code, just the $regfile directive. That way it can be tested.
- open file, chose F4 ? or manual program? It is important to use the same sequence as you do. So please include instructions on how it can be reproduced.
- please include the usbasp firmware hex file too. that way anybody can test it with minimum effort and too much guessing.

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

Bascom Member



Joined: 26 Feb 2006
Posts: 81

germany.gif
PostPosted: Tue Apr 14, 2015 10:13 pm    Post subject: Reply with quote

Hello Mark,

yes you wrote to everyone, but it also aims a little on me...
Quote:
- You can try to use a lower clock. if that does not solve it :


I have also tested a clock frequency at 93.75 kHz with the same result.
One more time: i can programm the device my be 3-5 times all is running ok,
then on time 6 an 7 it differs on adress 0 then running again several times ok, and then
fails again.

On the attachment there is the hex file for the programmer (ATmega8 12MHz Crystal Clock).

I have it tested with the bootloader example from bascom folder, only one adjust for Atmega328P.

But also with other programms, i get somtime the same error message.
When i read the flash back (after the error), i can see the old bin is in the chip, no erase and so on.



Code:

'----------------------------------------------------------------
'                          (c) 1995-2013, MCS
'                        Bootloader.bas
'  This sample demonstrates how you can write your own bootloader
'  in BASCOM BASIC
'  VERSION 2 of the BOOTLOADER. The waiting for the NAK is stretched
'  further a bug was resolved for the M64/M128 that have a big page size
'-----------------------------------------------------------------
'This sample will be extended to support other chips with bootloader
'The loader is supported from the IDE
$hwstack = 40
$swstack = 40
$framesize = 40
$crystal = 16000000
'$crystal = 14745600
$baud = 115200                                              'this loader uses serial com
'It is VERY IMPORTANT that the baud rate matches the one of the boot loader
'do not try to use buffered com as we can 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




'$regfile = "m8def.dat"

'Const Loaderchip = 8
'$regfile = "m168def.dat"
'Const Loaderchip = 168

'$regfile = "m16def.dat"
'Const Loaderchip = 16

'$regfile = "m32def.dat"
'Const Loaderchip = 32

$regfile = "m328pdef.dat"
Const Loaderchip = 328


'$regfile = "m88def.dat"
'Const Loaderchip = 88

'$regfile = "m162def.dat"
'Const Loaderchip = 162

'$regfile = "m8515.dat"
'Const Loaderchip = 8515

'$regfile = "m128def.dat"
'Const Loaderchip = 128

'$regfile = "m64def.dat"
'Const Loaderchip = 64

'$regfile = "m2561def.dat"
'Const Loaderchip = 2561


'$regfile = "m2560def.dat"
'Const Loaderchip = 2560

'$regfile = "m329def.dat"
'Const Loaderchip = 329

'$regfile = "m324pdef.dat"
'Const Loaderchip = 324


'$regfile = "m644def.dat"
'$regfile = "m644Pdef.dat"
'Const Loaderchip = 644


#if Loaderchip = 88                                         'Mega88
    $loader = $c00                                          'this address you can find in the datasheet
    'the loader address is the same as the boot vector address
    Const Maxwordbit = 5
    Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
#elseif Loaderchip = 168                                    'Mega168
    $loader = $1c00                                         'this address you can find in the datasheet
    'the loader address is the same as the boot vector address
    Const Maxwordbit = 6
    Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
#elseif Loaderchip = 32                                     ' Mega32
    $loader = $3c00                                         ' 1024 words
    Const Maxwordbit = 6                                    'Z6 is maximum bit                                   '
    Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
#elseif Loaderchip = 328                                    ' Mega32
    $loader = $3c00                                         ' 1024 words
    Const Maxwordbit = 6                                    'Z6 is maximum bit                                   '
    Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
#elseif Loaderchip = 8                                      ' Mega8
    $loader = $c00                                          ' 1024 words
    Const Maxwordbit = 5                                    'Z5 is maximum bit                                   '
    Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
#elseif Loaderchip = 161                                    ' Mega161
    $loader = $1e00                                         ' 1024 words
    Const Maxwordbit = 6                                    'Z6 is maximum bit                                   '
#elseif Loaderchip = 162                                    ' Mega162
    $loader = $1c00                                         ' 1024 words
    Const Maxwordbit = 6                                    'Z6 is maximum bit                                   '
    Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
#elseif Loaderchip = 8515                                   ' Mega8515
    $loader = $c00                                          ' 1024 words
    Const Maxwordbit = 5                                    'Z6 is maximum bit                                   '
    Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
    Osccal = &HB3                                           ' the internal osc needed a new value
#elseif Loaderchip = 64                                     ' Mega64
    $loader = $7c00                                         ' 1024 words
    Const Maxwordbit = 7                                    'Z7 is maximum bit                                   '
    Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
#elseif Loaderchip = 128                                    ' Mega128
    $loader = &HFC00                                        ' 1024 words
    Const Maxwordbit = 7                                    'Z7 is maximum bit                                   '
    Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
#elseif Loaderchip = 2561                                   ' Mega2561
    $loader = &H1FC00                                       ' 1024 words
    Const Maxwordbit = 7                                    'Z7 is maximum bit                                   '
    Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
#elseif Loaderchip = 2560                                   ' Mega2560
    $loader = &H1FC00                                       ' 1024 words
    Const Maxwordbit = 7                                    'Z7 is maximum bit                                   '
    Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
#elseif Loaderchip = 16                                     ' Mega16
    $loader = $1c00                                         ' 1024 words
    Const Maxwordbit = 6                                    'Z6 is maximum bit                                   '
    Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
#elseif Loaderchip = 329                                    ' Mega32
    $loader = $3c00                                         ' 1024 words
    Const Maxwordbit = 6                                    'Z6 is maximum bit                                   '
    Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
#elseif Loaderchip = 324                                    ' Mega32
    $loader = $3c00                                         ' 1024 words
    Const Maxwordbit = 6                                    'Z6 is maximum bit                                   '
    Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
#elseif Loaderchip = 644                                    ' Mega644P
    $loader = $7c00                                         ' 1024 words
    Const Maxwordbit = 7                                    'Z7 is maximum bit                                   '
    Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
#endif


Const Maxword =(2 ^ Maxwordbit) * 2                         '128
Const Maxwordshift = Maxwordbit + 1
Const Cdebug = 0                                            ' leave this to 0

#if Cdebug
   Print Maxword
   Print Maxwordshift
#endif



'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 , Spmcrval As Byte                            ' self program command byte value

Dim Z As Long                                               'this is the Z pointer word
Dim Vl As Byte , Vh As Byte                                 ' these bytes are used for the data values
Dim Wrd As Word , Page As Word                              'these vars contain the page and word address
Dim Bkind As Byte , Bstarted As Byte
'Mega 88 : 32 words, 128 pages



Disable Interrupts                                          'we do not use ints


Waitms 100                                                  'wait 100 msec sec
'We start with receiving a file. The PC must send this binary file

'some constants used in serial com
Const Nak = &H15
Const Ack = &H06
Const Can = &H18

'we use some leds as indication in this sample , you might want to remove it
#if Loaderchip = Not 328
   Config Pinb.2 = Output
   Portb.2 = 1                                              'the stk200 has inverted logic for the leds
   Led1 Alias Portb.2
   Config Pinb.3 = Output
   Portb.3 = 1
   Led2 Alias Portb.3
#endif

#if Loaderchip = 328
   Config Portb.5 = Output
   Led1 Alias Portb.5
#endif

$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
Testfor123:
#if Cdebug
    Print "Try " ; Bretries
    Print "Wait"
#endif
Bstatus = Waitkey()                                         'wait for the loader to send a byte
#if Cdebug
   Print "Got "
#endif

Print Chr(bstatus);

If Bstatus = 123 Then                                       'did we received value 123 ?
   Bkind = 0                                                'normal flash loader
   Goto Loader
Elseif Bstatus = 124 Then                                   ' EEPROM
   Bkind = 1                                                ' EEPROM loader
   Goto Loader
Elseif Bstatus <> 0 Then
   Decr Bretries
   If Bretries <> 0 Then Goto Testfor123                    'we test again
End If

For J = 1 To 10                                             ' 10! this is a simple indication that we start the normal reset vector
   Toggle Led1 : Waitms 100
Next

#if Cdebug
  Print "RESET"
#endif
Goto _reset                                                 'goto the normal reset vector at address 0


'this is the loader routine. It is a Xmodem-checksum reception routine
Loader:
  #if Cdebug
      Print "Clear buffer"
  #endif
  Do
     Bstatus = Waitkey()
  Loop Until Bstatus = 0


  For J = 1 To 3                                            'this is a simple indication that we start the normal reset vector
     Toggle Led1 : Waitms 50
  Next

  If Bkind = 0 Then
     Spmcrval = 3 : Gosub Do_spm                            ' erase  the first page
     Spmcrval = 17 : Gosub Do_spm                           ' re-enable page
  End If


Bretries = 10                                               'number of retries

Do
  Bblocklocal = 1
  Bstarted = 0                                              ' we were not started yet
  Csum = 0                                                  'checksum is 0 when we start
  Print Chr(nak);                                           ' firt time send a nack
  Do

    Bstatus = Waitkey()                                     'wait for statuse 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 Writepage                           'yes go write the page
                  Print Chr(ack);                           'acknowledge
                  Incr Bblocklocal                          'increase local block count
               Else                                         'no match so send nak
                  Print Chr(nak);
               End If
            Else
               Print Chr(nak);                              'blocks do not match
            End If
       Case 4:                                              ' end of transmission , file is transmitted
             If Wrd > 0 And Bkind = 0 Then                  'if there was something left in the page
                 Wrd = 0                                    'Z pointer needs wrd to be 0
                 Spmcrval = 5 : Gosub Do_spm                'write page
                 Spmcrval = 17 : Gosub Do_spm               ' re-enable page
             End If
            '  Waitms 100                                   ' OPTIONAL REMARK THIS IF THE DTR SIGNAL ARRIVES TO EARLY
             Print Chr(ack);                                ' send ack and ready
             #if Loaderchip = Not 328
               Led2 = 0                                     ' simple indication that we are finished and ok
             #endif

             #if Loaderchip = 328
               Led1 = 0
             #endif
             Waitms 20
             Goto _reset                                    ' start new program
       Case &H18:                                           ' PC aborts transmission
             Goto _reset                                    ' ready
       Case 123 : Exit Do                                   'was probably still in the buffer
       Case 124 : Exit Do
       Case Else
          Exit Do                                           ' no valid data
    End Select
  Loop
  If Bretries > 0 Then                                      'attempte left?
     Waitms 1000
     Decr Bretries                                          'decrease attempts
  Else
     Goto _reset                                            'reset chip
  End If
Loop



'write one or more pages
Writepage:
 If Bkind = 0 Then
   For J = 1 To 128 Step 2                                  'we write 2 bytes into a page
      Vl = Buf(j) : Vh = Buf(j + 1)                         'get Low and High bytes
      lds r0, {vl}                                          'store them into r0 and r1 registers
      lds r1, {vh}
      Spmcrval = 1 : Gosub Do_spm                           'write value into page at word address
      Wrd = Wrd + 2                                         ' word address increases with 2 because LS bit of Z is not used
      If Wrd = Maxword Then                                 ' page is full
          Wrd = 0                                           'Z pointer needs wrd to be 0
          Spmcrval = 5 : Gosub Do_spm                       'write page
          Spmcrval = 17 : Gosub Do_spm                      ' re-enable page

          Page = Page + 1                                   'next page
          Spmcrval = 3 : Gosub Do_spm                       ' erase  next page
          Spmcrval = 17 : Gosub Do_spm                      ' re-enable page
      End If
   Next

 Else                                                       'eeprom
     For J = 1 To 128
       Writeeeprom Buf(j) , Wrd
       Wrd = Wrd + 1
     Next
 End If
 Toggle Led1 : Waitms 10 : Toggle Led1                      'indication that we write
Return


Do_spm:
  Bitwait Spmcsr.0 , Reset                                  ' check for previous SPM complete
  Bitwait Eecr.1 , Reset                                    'wait for eeprom

  Z = Page                                                  'make equal to page
  Shift Z , Left , Maxwordshift                             'shift to proper place
  Z = Z + Wrd                                               'add word
  lds r30,{Z}
  lds r31,{Z+1}

  #if _romsize > 65536
      lds r24,{Z+2}
      sts rampz,r24                                         ' we need to set rampz also for the M128
  #endif

  Spmcsr = Spmcrval                                         'assign register
  spm                                                       'this is an asm instruction
  nop
  nop
Return


'How you need to use this program:
'1- compile this program
'2- program into chip with sample elctronics programmer
'3- select MCS Bootloader from programmers
'4- compile a new program for example M88.bas
'5- press F4 and reset your micro
' the program will now be uploaded into the chip with Xmodem Checksum
' you can write your own loader.too
'A stand alone command line loader is also available


'How to call the bootloader from your program without a reset ???
'Do
'   Print "test"
'   Waitms 1000
'   If Inkey() = 27 Then
'      Print "boot"
'      Goto &H1C00
'   End If
'Loop

'The GOTO will do the work, you need to specify the correct bootloader address
'this is the same as the $LOADER statement.
 


Best Regards

Josef
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 6198
Location: Holland

blank.gif
PostPosted: Tue Apr 14, 2015 10:55 pm    Post subject: Reply with quote

i tried it with an M88p and the bootloader.
it always works correct at a clock of 93 Khz and 187 KHz.
But when i increase clock, i get faults.
The chip runs at 8 MHz so it should allow a clock up to 2 MHz.
It could be a timing issue. But i do not understand why it fails for you when you use 93 KHz.
I will see why it fails at high speed. I think that is the problem.

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

Bascom Member



Joined: 26 Feb 2006
Posts: 81

germany.gif
PostPosted: Wed Apr 15, 2015 10:49 am    Post subject: Reply with quote

What surprises me, when i change the clockfrequency to the low speed (93..KHz), the hole programming time is the same as with 750 kHz.

It may be, the change in the settings are not done, before bascom is closed and restarted?


Regards

Josef
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 6198
Location: Holland

blank.gif
PostPosted: Wed Apr 15, 2015 9:32 pm    Post subject: Reply with quote

that surprised me too.
My usbasp firmware was older so i uploaded the latest. This was the one you included too.
Myboard has a jumper setting for slow clock mode. when it is set, the clock is always the same.
When it is not set, the setting from the options is used.
Now i made several changes : new firmware, set clock each time before programming, and add a small delay after opening the usb device.

The clock works as expected. It could be that my old firmware did not support the clock option, or it could be that the clock must be set each time as i do now.
Since you used the latest firmware already , setting the clock option each time seems to make a big difference. All other programmers only require to set the clock once. But i guess the setting is somehow reset when leaving the program mode.

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

Bascom Member



Joined: 26 Feb 2006
Posts: 81

germany.gif
PostPosted: Wed Apr 15, 2015 11:21 pm    Post subject: Reply with quote

Hello Mark,

Quote:
Now i made several changes : new firmware, set clock each time before programming, and add a small delay after opening the usb device.


Which parameters i must change, to get the small delay after opening the usb device?
Or is it connected with a new Bascom Version?

Best Regards

Josef
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 6198
Location: Holland

blank.gif
PostPosted: Thu Apr 16, 2015 3:05 pm    Post subject: Reply with quote

you need an update. when you write to support(and with you i mean only you) you can get a test version.
_________________
Mark
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
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