'*******************************************************************************
' FILENAME: ATXMEGA128A1 EEPROM Test x.bas
'
' PROCESSOR: ATXMEGA128A1
' CLOCK: 16Mhz XTAL
' TITLE:
' BOARD: 0420-04 and 0420-01
' MODIFIED: 3-DEC-2021
' AUTHOR: Frank Thomson
'*******************************************************************************
$regfile = "xm128A1Udef.dat" '"xm128A1Udef.dat" ' "C:\MCS\BASCAVR2082\DAT\xm128A1Udef.dat"
$framesize = 200 ' After global variables then after unused SRAM, grows bottom up, string conversion routines (PRINT, LCD, INPUT) require a buffer in SRAM
$swstack = 200 ' ISR routine parameters and grow top down
$hwstack = 200 ' Return address after routine call (SUB, FUNCTION, GOSUB) and grow top down
$crystal = 16000000
'Config Osc = Enabled , 32mhzosc = Enabled ' enable 2 MHz and 32 MHz internal oscillators
'Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1
Config osc = enabled , EXTOSC = enabled , 32KHZOSC=DISABLED, pllosc = enabled , range = 12MHZ_16MHZ , startup = XTAL_16KCLK , pllsource = extclock , pllmul = 1
Config Sysclock = PLL , Prescalea = 1 , Prescalebc = 1_1
CONFIG EEPROM=Quick ' <-- This must be defined as Mapped or Quick. Leaving this out and eeprom does not work
Disable Jtag
'--------{INITIALSE SOFT I2C}----------------------------------
'$FORCESOFTI2C
'Config I2cdelay = 10
'$lib "i2c.lbx" ' Software I2C
'----{ INITIALIZE HARDWARE}------------------------------------
' PORTS A,B, C, D, E, F, H, J, K, Q Default to ALL INPUTS on Reset
' Port D which has a LED
'PORT D.0 - 0 0 LED SPARE 2
' D.1 - 0 0 LED SPARE 1
' D.2 - 0 0 LED FAIL
' D.3 - 0 0 LED STATUS
' D.4 - 0 0 LED TESTING
' D.5 - 0 0 LED DEVICE
' D.6 - 0 0 Reserved for USB N
' D.7 - 0 0 Reserved for USB N
' 76543210
Config PortD = &B00000011
PortD = &B00000000
'--{SOFTWARE I2C}-------------------------
'config sda = portF.0
'Config SCL = PortF.1
'I2cinit
'---- INITIALISE COMMS ---------------------------------------------------------------------
Config Com5 = 9600 , mode = ASYNCHRONEOUS, Parity = None , Stopbits = 1 , Databits = 8
Open "COM5:" For Binary As #6
Config Serialin6 = Buffered , Size = 10
'--{VARIABLES}-------------------------
Dim LEDcounter as word
Dim B as byte
Dim Temp_str As String * 16
Dim Blank As Eram Word At 0
dim EE_MySerialNumber as ERAM string * 4
dim EE_B as ERAM Byte
'-----MAIN PROGRAM START---------------------------------------------------------------------
EE_B = 99
B = EE_B
Print #6, "B= "; B
EE_MySerialNumber = "1234"
Temp_str = EE_MySerialNumber
Print #6, "EE_MySerialNumber= "; Temp_str
portd.0 = 1 ' LED SPARE 2 ON
Print #6 ,
print #6, "AT X Mega 128A1U EEPROM Test Program"
loopforever:
' Heartbeat LED
LEDcounter = LEDcounter + 1
if LEDcounter >= 60000 then
toggle portd.1 'FAIL LED ON OFF
LEDcounter = 0
end if
goto loopforever |