I've been using GCBasic for programming PICs for a couple of years now and I love it. However, lately I've been experimenting with with some AVR chips, specifically ATTiny13 and ATTiny2313 just to expand my experience with microcontrollers. I heard that GCBasic supports AVR chips but I haven't found any examples in the forums, so I took an old LCD program originally written for the PIC 16F628A chip and modified it for the ATTiny2313. However, when I try to compile the program I get the following error: "Error: GCASM: Symbol SYSCOPYTEMP has not been defined." A hex file is created but, when I program the 2313, it doesn't seem to run. Here's the code I wrote. Hopefully someone can point me in the right direction. Thanks in advance.
' LCD connection settings
#define LCD_IO 4 ' LCD Display mode: 4-bit or 8-bit.
'#define LCD_DATA_PORT PORTB ' Use all of PORTB for data output when using 8-bit mode.
#define LCD_RS PORTD.0 ' Set PORTA pin 0 to control LCD's RS line.
#define LCD_RW PORTD.1 ' Set PORTA pin 1 to control LCD's RW line.
#define LCD_Enable PORTD.2 ' Set PORTA pin 2 to control LCD's Enable line.
#define LCD_DB4 PORTB.4 ' Must define pins for data output when selecting
#define LCD_DB5 PORTB.5 ' 4-bit mode. Otherwise, use LCD_DATA_PORT when
#define LCD_DB6 PORTB.6 ' using 8-bit mode.
#define LCD_DB7 PORTB.7
Wait 2 s
Top:
PRINT "Hello World!"
LOCATE 1, 0
PRINT "How are you?"
WAIT 3 s
CLS
PRINT "I am fine,"
' Scroll the words "Thank You." across the screen, from right to left.
FOR Cntr = 15 to 0 step -1
LOCATE 1, Cntr
PRINT "Thank you. "
WAIT 200 ms
NEXT
WAIT 3 s
CLS
GOTO Top
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry, just realized that my comments regarding PORTA don't match the actual port being used (PORTD) but that shouldn't affect the program since it's just the comments that are wrong.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
That was an easy one to fix, there was a bug in the Dir command when setting the whole port. You can download the fix from the usual place (http://gcbasic.sourceforge.net/newfiles/update.zip or newfiles/update-nochipdata.zip), or remove the Dir commands (the LCD code will set its pins up automatically).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for such a speedy reply. That took care of the compile error. I did find something else that seems a little strange, at least to me. If I used the line "#chip tiny2313, 8" the entire program ran about twenty times slower than normal. If I change the line to "#chip tiny2313, 1" everything seems to run at normal speed. Not sure why that is, but at least that's something I can work around. Thanks again for your help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The obvious question: what speed is the chip running at? Tiny2313 chips are set to run at 1 MHz when shipped - they have the RC circuit set to generate 8 MHz, but this is fed into a prescaler that divides it by 8. Unlike the PICs, I don't think there is any way that GCBASIC can set the clock speed of the AVR.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I believe you're right about not being able to set the clock speed from GCBasic. Looks like I may be able to change the fuse settings from within the programmer, though. I'll have to try it out.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've been using GCBasic for programming PICs for a couple of years now and I love it. However, lately I've been experimenting with with some AVR chips, specifically ATTiny13 and ATTiny2313 just to expand my experience with microcontrollers. I heard that GCBasic supports AVR chips but I haven't found any examples in the forums, so I took an old LCD program originally written for the PIC 16F628A chip and modified it for the ATTiny2313. However, when I try to compile the program I get the following error: "Error: GCASM: Symbol SYSCOPYTEMP has not been defined." A hex file is created but, when I program the 2313, it doesn't seem to run. Here's the code I wrote. Hopefully someone can point me in the right direction. Thanks in advance.
#chip tiny2313, 8
'#config OSC = OSC_INTOSC_NOCLKOUT, MCLRE = OFF, PWRTE = OFF, CP = OFF, WDT = OFF, BOREN = OFF
dir PORTD out
dir PORTB out
' LCD connection settings
#define LCD_IO 4 ' LCD Display mode: 4-bit or 8-bit.
'#define LCD_DATA_PORT PORTB ' Use all of PORTB for data output when using 8-bit mode.
#define LCD_RS PORTD.0 ' Set PORTA pin 0 to control LCD's RS line.
#define LCD_RW PORTD.1 ' Set PORTA pin 1 to control LCD's RW line.
#define LCD_Enable PORTD.2 ' Set PORTA pin 2 to control LCD's Enable line.
#define LCD_DB4 PORTB.4 ' Must define pins for data output when selecting
#define LCD_DB5 PORTB.5 ' 4-bit mode. Otherwise, use LCD_DATA_PORT when
#define LCD_DB6 PORTB.6 ' using 8-bit mode.
#define LCD_DB7 PORTB.7
Wait 2 s
Top:
PRINT "Hello World!"
LOCATE 1, 0
PRINT "How are you?"
WAIT 3 s
CLS
PRINT "I am fine,"
' Scroll the words "Thank You." across the screen, from right to left.
FOR Cntr = 15 to 0 step -1
LOCATE 1, Cntr
PRINT "Thank you. "
WAIT 200 ms
NEXT
WAIT 3 s
CLS
GOTO Top
Sorry, just realized that my comments regarding PORTA don't match the actual port being used (PORTD) but that shouldn't affect the program since it's just the comments that are wrong.
That was an easy one to fix, there was a bug in the Dir command when setting the whole port. You can download the fix from the usual place (http://gcbasic.sourceforge.net/newfiles/update.zip or newfiles/update-nochipdata.zip), or remove the Dir commands (the LCD code will set its pins up automatically).
Thanks for such a speedy reply. That took care of the compile error. I did find something else that seems a little strange, at least to me. If I used the line "#chip tiny2313, 8" the entire program ran about twenty times slower than normal. If I change the line to "#chip tiny2313, 1" everything seems to run at normal speed. Not sure why that is, but at least that's something I can work around. Thanks again for your help.
The obvious question: what speed is the chip running at? Tiny2313 chips are set to run at 1 MHz when shipped - they have the RC circuit set to generate 8 MHz, but this is fed into a prescaler that divides it by 8. Unlike the PICs, I don't think there is any way that GCBASIC can set the clock speed of the AVR.
I believe you're right about not being able to set the clock speed from GCBasic. Looks like I may be able to change the fuse settings from within the programmer, though. I'll have to try it out.