ATtiny Assembler Programming Part 6 The Timer

Поділитися
Вставка
  • Опубліковано 21 жов 2024

КОМЕНТАРІ • 15

  • @nickjenkins3592
    @nickjenkins3592 3 роки тому

    You are a gem, sir! Your tutorials provide a truly valuable service.

    • @DownhillAllTheWay
      @DownhillAllTheWay  3 роки тому

      Oh, don't say that - I'll never get my head through the door!
      I haven't used the AT85 for a few years, but I came back to it recently to make a stroboscope, and I'm thinking of doing another tutorial on that, as it used both timers in the chip and also the A-D converter. It works quite well, though its adjustment at high flash rates (>200 fps) becomes quite coarse, so it should really be re-designed with a range switch in it. Well, I'm not sure that I'm that keen, or that I want a stroboscope that badly, but keep an eye on the channel.

  • @peterjordaan8352
    @peterjordaan8352 3 роки тому

    Great tutorials Mike! Thank you for all the time you've spent making this available, it has helped me a great deal at my ripe old age and also convinced me to learn assembler.

    • @DownhillAllTheWay
      @DownhillAllTheWay  3 роки тому

      From one old man to another, thanks for the comment, Peter. I made the course a few years ago, and I haven't touched the AT85 since, but I have come back to it in the last few weeks, and I'm working on a stroboscope (and struggling!), which will read a potentiometer with the A-D converter, and feed the result to Timer_0 to generate the light-pulse repetition rate, and the length of the pulse will be controlled with with Timer_1. There may be another tutorial in due course.
      I'm writing the application in Assembler, but to be honest, I'm starting to wonder if it's a good idea. You have to accept that all computers run machine language, and it's different for each series of chips. It is the job of the compiler to turn your written code into machine language - a language in which each machine instruction (in the case of the AVR chips) is a 2-byte string of 1's and 0's.
      Assembler is a language in which you can write words like ADD, SUB(tract), MOV(e), etc, which have more meaning in English than does a string of binary digits, but I have seen several queries about whether C or ASM is more efficient, because people have written small applications in both languages and found the C to perform faster, or with fewer machine instructions. Of course, you can de-compile a C-program to find out what Assembler-based code it has produced, so you can find out why it was better than your own ASM code.
      When you read C-code that has been written for the AVR chips, you see immediately that it is kept very close to the hardware, referring to registers by name etc, it produces pretty tight machine language - and frankly, C is far more intuitive.

    • @peterjordaan8352
      @peterjordaan8352 3 роки тому

      @@DownhillAllTheWay I used to program in basic (bascom) but prefer assembler as most of my projects are quite simple and for own usage.C-code will allways be Greek to me!
      Waiting for the next tut good luck and thanks again.

  • @colingaywood1961
    @colingaywood1961 3 роки тому

    Thanks Mike for a great set of videos. These really helped me with my home projects using AVRs.

  • @rubensalves3899
    @rubensalves3899 6 років тому +3

    congratulations, very good!

  • @jeanpierredaviau7478
    @jeanpierredaviau7478 4 роки тому +1

    Live long and prosper

    • @DownhillAllTheWay
      @DownhillAllTheWay  4 роки тому

      Merci, Jean Pierre. How did it go - did you get right through the course? If so, you may be the first to have done so. Do you have a project in mind? I saw somebody on UA-cam had made a voice recorder with it by using the A-D and D-a converters. It wasn't that great - but I still thought it was a good project. I think it held about 5 seconds of speech. The AT85 is only a little chip - but the world is full of little applications.
      I'm busy learning (again, with a lot of difficulty) the STM32H7 chips (with the ARM core). I want to make a POV globe, which will be turned by a motor at 900 RPM, which is one revolution every 66667uS, but I don't want to complicate my work bench with the motor yet, so I used an AT85 to produce a 10uS pulse every 66667uS to simulate the index pulse from the motor. They're useful little chips.

    • @jeanpierredaviau7478
      @jeanpierredaviau7478 4 роки тому

      @@DownhillAllTheWay I could make a dimmer with your project. I started to learn assembly on windows 20 years ago and I gave up. It is a hobby, I went on java, then C , C++ . Then Arduino.
      Last year I tried Atmel studio (after a video from Joop Brokking) but I gave up because of the lack of informations for the beginners.
      Here I am banging my head on your code. I am progressing but my ability to memorise
      grows weaker with time. There is a lot to memorise ...
      You gave me an opportunity to make peace with assembly and Atmel.
      I would had like to have that software in the past.
      Regards
      JPD

    • @DownhillAllTheWay
      @DownhillAllTheWay  4 роки тому +1

      @@jeanpierredaviau7478 Courage, Jean Pierre. Tu y arrivera. If you need help, drop me a comment. If I can help, I will, or otherwise, the guys at AVRFreaks know what they're talking about. They spend all their time programming these chips, and helped me several times when I was struggling.

  • @louisferreira9055
    @louisferreira9055 4 роки тому +1

    Hi Mike, great videos! Thanks for taking the time to make them and upload.... I know how time consuming they are! I stumbled on your video series while I was looking for a timing circuit for a retro 6502 computer project I am working on, and realised that the AT85 chip may be the best and simplist way to provide the clock for it, in as much as it can be made to have the frequency changed via a potentiometer, and even be stopped (and single stepped) for debugging purposes. I am not too familiar with assm language (yet) and for some reason I could not get Atmel Studio to work on my PC, and so could not follow along with this series. So would it be possible for you to create a quick video on how to make a simple clock circuit, but using Arduino IDE and Uno? Many of us UA-camrs and hobiiests lack your advanced knowledge of these chips and IDE environments to be able to make sense of it all, but would love to learn about them using tools we already know.

    • @DownhillAllTheWay
      @DownhillAllTheWay  4 роки тому

      6502? - Aah! The good ol' days! In those days, I was all into Z80s.
      Thanks for your kind words, Louis, however, don't think of me as an expert on the AVR chips. I struggled with them, then passed the learning on to make it easier for other people - but that doesn't make me a guru!
      If you want to drive your timer with a pot, you'll have to attack the A-D converter, which I did not cover in this series. However, with what I said about the timer (the peripheral I _did_ cover), it should be relatively easy to move to the A-D (with the help of the DataSheet). If you are coming to it for the first time, it will take a bit of figuring out - don't count on anything less than a couple of weeks unless you're much brighter than I am (which isn't hard to believe!) I see that somebody has put an A-D tutorial for the AT85 on UA-cam. It looks similar in detail to my course, and it uses C-language. ua-cam.com/video/BC5LSnm9R9k/v-deo.html
      When I said that I made the course to pass on hard-won knowledge, I wasn't kidding. What I presented there was the product of many months learning - then the videos took a couple of weeks to make, with presentation software I had to learn before using it (OBS Studio), and loads of time on Windows Movie Maker editing out all the "um"s and "er"s. I didn't have the benefit of any course - I was just sitting alone at home, finding out what I could by playing with the chip and asking questions on the AVRFreaks forum. The guys there are very knowledgeable, but not always the most patient with newbies, I found. Still - the journey is the reward!
      I specifically wanted to learn assembler, so I haven't used C on these chips. I did a couple of projects, both outlined in the intro, and I haven't touched the chip again till a few days ago. I'm currently working on a project on the ARM H743 chip, which will be doing a lot of stuff, among which, it will control a motor to run at a precise 15 revs per second. The motor shaft will have a sensor that will give one pulse per revolution - but I wanted to get on with developing the software on the ARM chip before making the hardware, which will be time-taking and expensive, so I turned to the AT85 to make me an 80 microsecond pulse every 66667 microseconds, to spoof the hardware. Even a simple project like that took me a couple of days to work out, but it's working now. I'm not finding the ARM easy to get into, so generating the project on it will take all my time for the next year, probably.
      Good luck with your challenge. If you bang your head against it for long enough, you'll get there, and once you do, the AVR chips will become a new world of possibilities for you. I could have done my timer with a 556 and some caps and resistors, but a programmed AT85 gives me a much more reliable timing pulse.
      I would STRONGLY advise you to get Atmel Studio-7 working (AS7). In my experience, it's a dream compared with the Arduino compiler. I run a Windows-7 laptop, but I would guess it should run on Windows-10, or otherwise, you may have to run it in emulation mode. I believe there is no Linux or Apple version of it. For me, it was just a case of downloading it and installing it, and it worked. You can program in Asm or in C, and it fully emulates the chip and allows single-stepping etc, counts cycles, shows uS elapsed, shows all register contents, shows the peripherals' internals and what's going on there, and if you use C, it will show the assembler steps it has compiled your program into - but you don't have to look at that - it's not primarily an Assembler-biassed package. Once you get it installed, you may find my video on it useful. For the pulse I wanted in my latest AT85 effort, I did all my programming on AS7, and got it completely working before I even went looking for my stash of chips. Then downloading it to a chip took 5 minutes (I still have an Arduino Nano with the programmer code on it, on a little board with a chip socket for the ATTiny85, then I put it in a breadboard and powered it up, connected an oscilloscope, and hey Presto! - there was my pulse.

    • @jeanpierredaviau7478
      @jeanpierredaviau7478 4 роки тому

      @@DownhillAllTheWay it run on Windows-10