Menu

ATMEGA4809 family chips

GCBASIC
2022-03-27
2024-10-02
<< < 1 2 3 4 5 .. 8 > >> (Page 3 of 8)
  • cribcat

    cribcat - 2024-08-21

    Here is Timer Counter A Splitmode PWM. Splits the 16bit timer to function as two 8 bit PWMs.

     

    Last edit: cribcat 2024-08-21
  • Anobium

    Anobium - 2024-08-21

    @cribcat ( I have added you to the DEV group, so, you should get a message to alert you).

    Greg,

    I think you may need to comment out the move vectors code to run on your boards... my fuses are wrong so I need that code.

    Can you explain ? I do not understand. What needs to be supported?

    Evan

     
  • cribcat

    cribcat - 2024-08-21

    When you initially set the fuses, there are bytes to set up the APPEND, BOOTEND
    which control the size of your main code section, your bootloader section, and your APPDATA section. I think I've gotten the sizes wrong in the fuses, so my MCU will not trigger any interrupts unless I put in the following code:

    move_vectors:                           ; TO BootSection
           ldi tmp2,CPU_CCP_IOREG_gc        ; CCP Change Protection
           ldi tmp, CPUINT_IVSEL_bm         ; vector select 1 == in boot section
           out CPU_CCP, tmp2                ;  Change Protection  
           sts CPUINT_CTRLA, tmp            ; 
    

    I have not seen any issues or mention of moving the vectors like this on forums so I'm assuming that I'm missing something. Maybe it is necessary. I program exclusively in ASM and people in the forums use "C" almost exclusively. The AVR-GCC compiler does things that you will never know about unless you look in the assembly listing... maybe that code is in there?

    Your boards probably come with all fuses set as well as a debugger/UPDI chip as a working unit . I buy the chips and solder them to breakout boards, no debugger so the chips have default factory settings. This is a problem I'm working on, but I have no answers at this point. If it works is ultimately all I care about. I don't know if the above code is required or not. The new AVR-0 / 1 chips aren't like the older AVRs.

     
    • Anobium

      Anobium - 2024-08-21

      The answer maybe for you to set the .org above the interrupt vectors. What you are describing looks the same as legacy AVR an LGTs. Have a look at set your org the same as the as the GCBASIC org, and, take all the vector stuff. Does that resolve?

       
  • cribcat

    cribcat - 2024-08-21

    That's a good suggestion, I have cut and pasted the Vector list from one of your demo's assembly listings a few days ago with no positive results.

    .ORG    0
        rjmp    BASPROGRAMSTART ;Reset
    .ORG    2
        reti    ;CRCSCAN_NMI
    .ORG    4
        reti    ;BOD_VLM
    .ORG    6
    
    ... etc.
    

    I will try it again. Since I started working on AVR-0/1 chips, I have spent days on this issue... which may not even be an issue except for my understanding of the basic MCU function. I might have to put in a ticket with Microchip. It wouldn't hurt to test it on your hardware to see what works for you, for now.

     
  • cribcat

    cribcat - 2024-08-21

    O.K. think I have it. The 0x1288 BOOTEND FUSE was set to 2 and I have no bootloader... anyway
    I changed your Loopback demo from USART3 to USART1 , set it to 57.6K, compiled it and ran it on the 4809. it seems to echo exactly what is typed after the (Splash Screen) message. It's good to see results ! Also thanks for the Honorable mention on your video.

     
    • Anobium

      Anobium - 2024-08-22

      So, I can document. Is BOOTEND = 0, and APPEND = 0 ?

      I will pull out and document the FUSES for the Microchip board.

       
  • cribcat

    cribcat - 2024-08-21

    The compiler successfully updated. Anything pressing that you need worked on? or shall I just press on?. Trying to work the most used peripherals first. You have Timer Counter A and B in PWM, Timer Counter B as a periodic interrupt. Is there anything with USART serial we need to address? I'll continue, Let me know if I need to switch gears.

     
  • cribcat

    cribcat - 2024-08-22

    Here's some pin operations to set and clear the pullup resistors and setting/clearing a pin with OUTSET/OUTCLR.

     
  • Angel Mier

    Angel Mier - 2024-08-22

    An outstanding work you and Evan are doing!

    Congratulations and keep the good work.

    Angel

     
  • cribcat

    cribcat - 2024-08-22

    Thanks Angel,
    step by step we will get there.
    Here is an example of a pin interrupt.

     
  • Anobium

    Anobium - 2024-08-22

    @cribcat re the question about what needs to be worked on - this may help.
    Ask any questions.

    NotS - Not Started
    ASM - ASM provided
    ERVBack - In Evan's Backlog
    WIP - Work In Progress
    DONE - Done!
    Cribcat - Item assigned to Greg

    Functionality Status Comments
    OSC Completed Demo published
    PIN Operations Completed Demo published
    Serial/USART Evan WIP Completed library. Now ensuring Serial Buffer Ring works.
    Interrupts ASM;ERVBACK Use the Serial, PIN, PWM and Timer ASM to verify handler
    Timers ASM;ERVBACK NotS
    millis() NotS This is an implementation of mills() at 16mHz ( I dont think the internal clock at 20mHZ will support millis(). This is essentially Timer0 interrupy every millsecond. See millis.h for implementation.
    I2C Cribcat Basic Init/Start/Send & Receive/End
    Memory DATA ERVBack This is ability to add DATA blocks to ASM. Currently NO AVR is supported!
    Memory PROGMEM Cribcat This self write capability/methods to write/read to PROGMEM
    Memory EEPROM Cribcat This self write capability/methods to write/read to EEPROM; and, for of EEPROM as defined in ASM
    PWM ASM;EvanBack
    Sleep ASM:ERVBAck Greg has provided example ASM

    For published demos - see https://github.com/GreatCowBASIC/Demonstration_Sources/tree/main/TestSolutions/AVRDX_implementation/mega4809

    I will add your ASM to GitHub - as a great reference!

    Have I missed anything / any ASM I have?

    Evan

     

    Last edit: Anobium 2024-08-25
  • cribcat

    cribcat - 2024-08-22

    @evanvennn : That list will do fine. Thank You. As far as what you already have... I've made a directory to put copies of all sent items , we can cross check if necessary. I see you have put them on github... good.
    The problem with moving the Vectors on my chip seems to have been solved by writing the correct fuse byte to BOOTEND. You can delete or comment out the move_vectors routine .

    move_vectors:                          ; TO BootSection
            ldi tmp2,CPU_CCP_IOREG_gc      ; CCP Change Protection 
            ldi tmp, CPUINT_IVSEL_bm       ; vector select 1 == in boot section
            out CPU_CCP, tmp2              ; Change Protection 
            sts CPUINT_CTRLA, tmp 
    

    Thanks
    Greg

     
    • Anobium

      Anobium - 2024-08-22

      :-)

       
  • cribcat

    cribcat - 2024-08-22

    I used Bret Mulvey 's delay loop calculatorfor my delays in my code. we should probably replace the delay loops with GCbasic assembled ones or give Bret credit?
    the website is now :http://darcy.rsgc.on.ca/ACES/TEI4M/AVRdelay.html
    I can do that if need be .

     
    • Anobium

      Anobium - 2024-08-22

      Great point.

      If you have time and you have access to GitHub you should attribute to the author. That would be the best solution.

       
  • cribcat

    cribcat - 2024-08-23

    MEGA4809_32K_OSC_TCB_PWM.asm Line 36 "|CLKCTRL_CLKOUT_bm" needs to be edited out . the line should be ldi tmp, CLKCTRL_CLKSEL_OSCULP32K_gc

    CLK OUT could pop something on your chip or damage whatever is connected to it if hooked up directly.(worst case scenario)

     
    • Anobium

      Anobium - 2024-08-23

      Can you re issue that demo? Then, I know I have it right.

       
  • cribcat

    cribcat - 2024-08-23

    Evan,
    What is this code supposed to do? I'm curious:
    "Memory DATA: This is ability to add DATA blocks to ASM. Currently NO AVR is supported!"

    I have a GitHub account but I can not edit/add documents on your GitHub. I have attached a little blurb for the delay loop webpage I mentioned yesterday. I don't publish on GitHub... so I'm ignorant of how it works.

    I will re post the " MEGA4809_32K_OSC_TCB_PWM.asm " updated code.

     
    👍
    1
    • Anobium

      Anobium - 2024-08-24

      Thanks for the TXT. I will upload.


      "Memory DATA: This is ability to add DATA blocks to ASM. Currently NO AVR is supported!"

      This is relatively simple. This is a block of PROGMEM that starts with a label.

      Here is the Help page - https://gcbasic.sourceforge.io/help/_data.html

      So, the format/structure that I need to implement for AVR is needed not an ASM example, and, validate the max value of PROGMEM ( 16f for example has a max number of 14bit/0x3FFF whereas the 18F has 16bit/0xFFFF. ).


      Currently, this is the state of play. GCBASIC is generating the ASM shown below.

      #chip mega4809
      
      DATA DataSet1 as Byte
          3,2,0x4000
      End DATA
      

      gives ASM generated

      ; DATA blocks. DATA blocks are contiguous and may, or may not, overlap page boundary(ies).
      DATASET1:
              dw 0x0003, 0x0002, 0x4000
      

      This looks ok, but, I think this all wrong. dw?, lable looks ok, is AVR 14bit ? So 0x4000 would be OK ?

      Any insights you can provide will help me update that bit of the compiler to ensure the ASM / HEX generated works!

      :-)

       
  • cribcat

    cribcat - 2024-08-23

    Here is the updated " MEGA4809_32K_OSC_TCB_PWM (updated).asm "

     
    • Anobium

      Anobium - 2024-08-24

      I have uploaded to GitHub. Thanks.

       
  • cribcat

    cribcat - 2024-08-23

    And here is a sleep demo. It's not on the work list, you may have already done it.

     
    • Anobium

      Anobium - 2024-08-24

      Great addition. I have basic SLEEP only.

      Thanks.

       
  • cribcat

    cribcat - 2024-08-24

    Here's my thoughts on Memory DATA.
    it got a little long so see the attached text.

     
<< < 1 2 3 4 5 .. 8 > >> (Page 3 of 8)

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.