Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

BASCOM AVR Programmer's Assistant

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here
View previous topic :: View next topic  
Author Message
enniom

Bascom Member



Joined: 20 Oct 2009
Posts: 537

PostPosted: Sun Jan 26, 2020 11:47 pm    Post subject: BASCOM AVR Programmer's Assistant Reply with quote

Hello,

During code development and troubleshooting, many programmers/developers send UART messages to a Terminal Program. As an alternative, I developed the AVR Programmer's Assistant.
It uses the same logic as an Excel Spreadsheet with addressable Columns and Rows. It also provides a Real-Time graph for streaming Live Data.






The AVR Programmer's Assistant is written in Python and the BASCOM Code is shown below:


Code:
'============================================
'            (c) 2020, enniom
'    BASCOM AVR Programmer's Assistant
'
'  Sample code interfacing with Python GUI
'============================================
$regfile = "xm192a3udef.dat"
$hwstack = 128
$swstack = 128
$framesize = 128

$version 1 , 0 , 22

'============================================
'====[ Config XMega Clock ]===================
'============================================
Osc_dfllctrl.0 = 1
Dfllrc32m_ctrl.0 = 1                                        'enable CALIBRATION

$crystal = 32000000
Config Osc = Disabled , 32mhzosc = Enabled                  ' 32 MHz enabled
Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1  'use 32 MHz

'============================================
'====[ USART XMega ]=========================
'============================================
'(
   COM1 - Uart_c0 Portc.3 Portc.2 Serialin Or Serialin0
   COM2 - UART_C1 PORTC.7 PORTC.6 SERIALIN1
   Com3 - Uart_d0 Portd.3 Portd.2 Serialin2
   COM4 - UART_D1 PORTD.7 PORTD.6 SERIALIN3
   COM5 - Uart_e0 Porte.3 Porte.2 Serialin4
   Com6 - Uart_e1 Porte.7 Porte.6 Serialin5
   COM7 - UART_F0 PORTF.3 PORTF.2 SERIALIN6
   COM8 - Uart_f1 Portf.7 Portf.6 Serialin7
')
Config Serialin6 = Buffered , Size = 64 , Bytematch = &H7F
Config Serialout6 = Buffered , Size = 64                    'Uses USARTF0_DRE Interrupt

Config Com7 = 115200 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8
Open "COM7:" For Binary As #1

Dim Column As Byte At _rs232inbuf7(3) Overlay
Dim Msg_ovl As String * 3 At _rs232inbuf7(5) Overlay
Dim Usart_ready As Byte

'============================================
'====[ Interrupt Priority ]==================
'============================================
Config Priority = Static , Vector = Application , Lo = Enabled , Med = Enabled , Hi = Enabled
Usartf0_ctrla.5 = 1 : Usartf0_ctrla.4 = 1                   'set high priority interrupt

'============================================
'====[ Config SOFT Clock ]===================
'============================================
Config Clock = Soft , Rtc = 1khz_int32khz_ulp , Gosub = Sectic       'select internal 1 KHz clock from the 32KHz internal oscillator
Config Date = Mdy , Separator = Dot

Date$ = "02.01.20" : Time$ = "00:00:00"

Dim Long_time As Long
Long_time = Syssec()

'============================================
'====[ Timer Example ]=======================
'============================================
Config Tcc1 = Normal , Prescale = 1024 , Resolution = Normal
Tcc1_per = &HFFFF                                           ' period register

On Tcc1_ovf Example_timer_isr
Enable Tcc1_ovf , Lo
Start Tcc1

Dim Timer_ready As Byte

'====[ Scratchpad Vars ]=====================
Dim I As Byte

Enable Interrupts

'====[ Setup Programmer Assistant ]==========

Print #1 , "T,A," ; "TIMER TCC1" ; ","                      'Column "A" Title
Print #1 , "A,1," ; "TCC1_CNT" ; ","                        'Use Comma-Delimited Messages
Print #1 , "A,4," ; "Timer_ready" ; ","                     'messages must end with "," CRLF

Print #1 , "B,1," ; "Hello World" ; ","                     'Comment inserted in COL "B" ROW 1

Print #1 , "T,C," ; "XMega RTC" ; ","                       'Column "C" TITLE
Print #1 , "C,1," ; "uC_Time" ; ","

Print #1 , "T,F," ; "What We Know" ; ","                    'Various examples
Print #1 , "F,1," ; "XMega    " ; _xmega ; ","              'Columns and Rows are addressable (eg: Excel)
Print #1 , "F,2," ; "Clk " ; _xtal ; ","
Print #1 , "F,3," ; "Num USARTS  " ; _uarts ; ","
Print #1 , "F,12," ; "Loop Count" ; ","

Waitms 50

'============================================
'====[ Main Loop ]===========================
'============================================

Do
'(


   Perform Other Tasks


')

   Incr I                                                   'loop count
   Waitms 50                                                'This may be reduced for PC's with fast processors

   '====[ Example Updates Using LIVE DATA ]=======
   '====[ This replaces messages normally ]=======
   '====[ sent to terminal program ....   ]=======
   Print #1 , "A,2," ; Hex(tcc1_cnt) ; ","                  'all Printable forms are supported
   Print #1 , "A,5," ; Timer_ready ; ","
   Print #1 , "C,3," ; Time$ ; ","
   Print #1 , "F,13," ; I ; ","                             'Addressable ROW range is 1-13

   Print #1 , "G,1," ; Timer_ready ; ","                    '"G,1" sends Data Feed to REAL-TIME Graph
   If Timer_ready > 0 Then Timer_ready = 0

   '====[ Example Sending Messages to uC  ]=======
   '====[ This replaces messages normally ]=======
   '====[ sent from terminal program ..   ]=======
   If Usart_ready = 1 Then
       Select Case Column                                   'A to F
            Case 65
            Case 66
            Case 67
               Print #1 , "C,13," ; Usart_ready ; ","
               _hour = Val(msg_ovl)
               Long_time = Syssec()
            Case 68
            Case 69
            Case 70
       End Select
       Clear Serialin6
       Usart_ready = 0
   Else
       If _sec = 0 Then Print #1 , "C,13," ; Usart_ready ; ","
   End If

Loop
End                                                         'Main Loop

'============================================
'====[ Interrupt Routines ]==================
'============================================
Serial6charmatch:
   'Pushall
   Usart_ready = 1
   'Popall
Return

Example_timer_isr:
   Incr Timer_ready
Return

Sectic:
     Incr Long_time
Return



The installation and operating instructions are included in the attached *.ZIP file.

Please provide feedback and improvements.

E
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Wed Jan 29, 2020 9:37 pm    Post subject: Reply with quote

hi Enniom,

thank you for taking the time to share.
it is very good documented. nice that you can have access from multiple pc's.
while the sample is for XMega it will work for other AVR as well Very Happy

_________________
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 -> Share your working BASCOM-AVR code here 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