Files
SyncHome/trunk/workspace/gcb/mega1284-BreadBoard.gcb
2023-03-09 12:51:54 +00:00

125 lines
3.5 KiB
Plaintext

' ########### start ###########
' avr:mega1284p
' ########### end ###########
'
' ******************************************************************
' EPROM Emulator with ATMega1284(p)
' 2016-08-23 (c) Paolo Iocco
' ******************************************************************
'
' Circuit diagram
' ATmega 1284 Pin map
' +-\/-+
' PB0--1|o |40--PA0----GLCD.RES
' PB1--2| |39--PA1----GLCD.CS
' PB2--3| |38--PA2----GLCD.DC
' PB3--4| |37--PA3----GLCD.DO
' PB4--5| |36--PA4----GLCD.SCK
' MOSI-PB5--6| |35--PA5
' MISO-PB6--7| |34--PA6
' SCK--PB7--8| |33--PA7
' /Reset 9| |32 AREF
' VCC 10| |31 GND
' GND 11| |30 AVCC
' XTAL1 12| |29--PC7
' XTAL2 13| |28--PC6
' RXD0---------PD0-14| |27--PC5
' TXD0---------PD1-15| |26--PC4
' PD2 16| |25--PC3
' PD3 17| |24--PC2
' PD4 18| |23--PC1
' PD5 19| |22--PC0
' PD6 20| |21 PD7
' +----+
' ******************************************************************
' 9.6MHz:
' LFuse: 0xxx; HFuse: 0xxx;
' AVRDude: -U lfuse:w:0xxx:m -U hfuse:w:0xxx:m
'
' ******************************************************************
#chip mega1284p,16
'#option explicit
#define GLCD_TYPE GLCD_TYPE_PCD8544
#include <glcd.h>
' Pin mapping
#define GLCD_RESET porta.0
#define GLCD_CS porta.1
#define GLCD_DC porta.2
#define GLCD_DO porta.3
#define GLCD_SCK porta.4
dim longNumber as long
dim wordNumber as word
dim byteNumber as byte
dim indexvalue as byte
dim CCount as byte
dim temp as byte
setup:
longNumber=0
wordNumber=0
byteNumber=0
Write_Command_PCD8544(0x21) 'Activate Chip and H=1.
Write_Command_PCD8544(0xC2) 'Set LCD Voltage
Write_Command_PCD8544(0x06) 'temperature correction
Write_Command_PCD8544(0x13) 'set bias system
Write_Command_PCD8544(0x20) 'set LCD mode:PDown=0, Vaddr=0, Hext=0
Write_Command_PCD8544(0x09) 'Activate all segments.
Clear_RAM_PCD8544() 'Erase all pixel on the DDRAM.
Write_Command_PCD8544(0x08) 'Blank the Display.
Write_Command_PCD8544(0x0C) 'Display Normal.
GLCDCLS
Table tabella as byte
0x01, 0x02, 0x03, 0x04
0x02, 0x03, 0x04, 0x05
0x03, 0x04, 0x05, 0x06
0x04, 0x05, 0x06, 0x07
end Table
GLCDPrint(0, 0, "Done.")
loop:
DO forever
pippo
LOOP
Sub pippo;
for CCount = 31 to 127
indexvalue = CCount/16
readtable Tabella,indexvalue,temp
GLCDPrint(0, 0, "PrintStr")
GLCDDrawString(0, 9, "DrawStr")
GLCDPrint(44, 21, " ")
GLCDPrint(44, 29, " ") ' word value
GLCDPrint(44, 37, " ") ' Byte value
GLCDPrint(44, 21, hex(longNumber_U))
GLCDPrint(56, 21, hex(longNumber_H))
GLCDPrint(68, 21, hex(longNumber))
GLCDPrint(44, 29, mid( str(wordNumber),1, 6))
GLCDPrint(44, 37, byteNumber)
box 46,9,57,19
GLCDDrawChar(48, 9, CCount )
FilledBox(58,9,GLCD_WIDTH-1,17,GLCDBackground ) 'draw a box to overwrite existing strings
GLCDPrint(58, 9, str( CCount ))
box 0,0,GLCD_WIDTH-1, GLCD_HEIGHT-1
box GLCD_WIDTH-5, GLCD_HEIGHT-5,GLCD_WIDTH- 1, GLCD_HEIGHT-1
Circle( 25,30,8,1)
'filledbox 2,30,6,38, wordNumber
'FilledCircle( 25,30,4,longNumber xor 1)
'line 0, GLCD_HEIGHT-1 , GLCD_WIDTH/2, (GLCD_HEIGHT /2) +1
'line GLCD_WIDTH/2, (GLCD_HEIGHT /2) +1 ,0, (GLCD_HEIGHT /2) +1
longNumber = longNumber + 7
wordNumber = wordNumber + 3
byteNumber++
NEXT
End Sub
end