A bit of bad luck here, as Random is a lowlevel function described in the GCBasic dir folder include/lowlevel/random.h. So use a different variable, or try the random function after proper initialization. Also:
1) Typo in #define led GPIO.1
2) Dim max_1, max_2, and max_3 as words
3) No need to dim byte size variables
4) As far as I know GCBasic has no bit variables
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm a little confused though, I was indeed attempting to use the Random function, ie assign a random number to my variable count_1. From the few examples I found of it's use is in the "level crossing.txt" in the Demo folder where is simply says...
wait Random ms
and I was under the impression that GCBasic was not case sensitive.
As for you other points, I'm afraid I'm not following you there either...
2) Dim max_1, max_2, and max_3 as words
Why do I need to define a constant as a variable? Again from the level crossing exmaple...
#define UpTime 2 'Number of flashes taken for gate to rise
I realise that is only a byte size constant rather than a word size, but there is no Dim for the constant.
4) As far as I know GCBasic has no bit variables
Bit is listed in the Help file under the Syntax section, along with byte, word, array and string, what isn't clear is how you set it up, it says that byte variables you can just use, anything bigger you need to Dim, but no mention of what to do with smaller ones.
Thanks again
Tom
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
OK, it seems most of the problems were a knock on affect from the typo.
I'm down to an issue that is I think a compiler bug where it is using the command ADDLW which isn't supported on the 12F508. I've reported this over in the Compiler forum.
Thanks for your help.
Tom
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Morning
When I compile my code I get a stack of errors when the ASM is being compiled. When I checked the ASM, the first thing I noticed was...
;Set aside memory locations for variables
(RANDOM equ 7
128) equ 8
COUNT_1 equ
MPASM doesn't like the bracket before RANDOM or that the next line begins with 1 - both of which I would expect.
The following is my code up to the first use of RANDOM...
#chip 12F508,4
#config MCLRE_OFF, IntRC_OSC, WDT_OFF
#define led GPOI.1
#define max_1 530
#define max_2 620
#define max_3 875
#define on_for 75
dim count_1 as word
dim count_2 as word
dim count_3 as word
dim on_timer as byte
dim on_off as bit
dir GPIO out
start:
; set random values to the 3 counters to prevent all starts being in sync
count_1 = random
Anyone any ideas what wrong?
Tom
A bit of bad luck here, as Random is a lowlevel function described in the GCBasic dir folder include/lowlevel/random.h. So use a different variable, or try the random function after proper initialization. Also:
1) Typo in #define led GPIO.1
2) Dim max_1, max_2, and max_3 as words
3) No need to dim byte size variables
4) As far as I know GCBasic has no bit variables
Thanks for your reply.
I'm a little confused though, I was indeed attempting to use the Random function, ie assign a random number to my variable count_1. From the few examples I found of it's use is in the "level crossing.txt" in the Demo folder where is simply says...
wait Random ms
and I was under the impression that GCBasic was not case sensitive.
As for you other points, I'm afraid I'm not following you there either...
2) Dim max_1, max_2, and max_3 as words
Why do I need to define a constant as a variable? Again from the level crossing exmaple...
#define UpTime 2 'Number of flashes taken for gate to rise
I realise that is only a byte size constant rather than a word size, but there is no Dim for the constant.
4) As far as I know GCBasic has no bit variables
Bit is listed in the Help file under the Syntax section, along with byte, word, array and string, what isn't clear is how you set it up, it says that byte variables you can just use, anything bigger you need to Dim, but no mention of what to do with smaller ones.
Thanks again
Tom
OK, it seems most of the problems were a knock on affect from the typo.
I'm down to an issue that is I think a compiler bug where it is using the command ADDLW which isn't supported on the 12F508. I've reported this over in the Compiler forum.
Thanks for your help.
Tom