Menu

ATtiny817-Xplained Mini + UNO Multifunction Shield demo

kent_twt4
2019-01-19
2019-01-27
  • kent_twt4

    kent_twt4 - 2019-01-19

    So I have been playing around with the ATtiny817_Xplained Mini along with an UNO Multifunction Shield of late. The ATtiny817 is one of the new tiny0-series, 1-series and mega 0-series type devices. They apparently borrow some of the Xmega archetecture, not personally familiar with those devices. They have lots of registers that are supposed to circumvent read-modify-write instructions, which means not having to read the register than OR the bits you want to change, you can just write the bits directly.

    If anyone plans to investigate these devices, or currently has one, here is GCB demo code to read an analog input, in this case a pot on the MFS, and send it out to a terminal on the alternate USART TX pin. The .dat file is really a mess at the moment and not suitable for publication. If someone wants to have a play, I could email the dat file thru Sourceforge account.

    #chip tiny817Xa,3.333333
    
    '*****USART*****
    'DTR pin needs to be set for the ATtiny817-Xplained-mini board
    'to communicate with a Terminal program!!!
    'Default Usart is a loaded pin on the Multi-Function Shield (MFS)
    'so use alternate pins provided by PortMux
    #define USART_BAUD_RATE 9600
    #define USART_TX_BLOCKING
    'define alias's for attiny 0-series, 1 series to work with GCB commands
    #define UDR0 Usart0_TXDATAL
    #define UDRE Usart0_Status.DREIF
    'set up attiny 0-series, 1 series initialization registers manually
    Usart0_CTRLC = 0b00000011   'asynchronous, no parity, 1 stop bit, 8bits
    'Usart0_Baud = 1389   '64*3333333/(16*9600) asynch
    Usart0_BaudH = 0b00000101
    Usart0_BaudL = 0b01101101
    Usart0_CTRLB = 0b01000000   'enable TXEN bit
    'change usart0 to alternate pins PA1(TX), and PA2(RX)
    PortMux_CTRLB = 0b00000001
    PortA_DirSet = 0b00000010   'alternate TX pin at PA1
    
    '*****ADC*****
    'PA4 is Pot_Pin on MFS
    PortA_CLR = 0b00000100
    
    Do
      HSerPrint ReadPot
      HSerPrintCRLF
      wait 1 s
    Loop
    
    Function ReadPot as Word
      'VDD bit4=1(Internal=0),CLCK DIV4
      ADC0_CTRLC = 0b00010001
      '10bit resolution bit2=0/8bit bit2= 1, ADC_Enable bit0
      ADC0_CTRLA = 0b00000001
      ADC0_MUXPOS = 0b00000100  'PA4, A0 on MFS
      ADC0_COMMAND = 0b00000001 'start conversion
      Wait Until ADC0_INTFLAGS.0 = 1  'RESRDY flag Works
      'need to clear flag before next conversion
      ADC0_INTFLAGS.0 = 0
      ReadPot = ADC0_RESL
      ReadPot_H = ADC0_RESH
    
    end Function
    
     
  • Derek

    Derek - 2019-01-27

    Thanks for your hard work on this kent_twt4

     

Log in to post a comment.