Hello everyone,
I am building a set of stereo controls and am using a lot of DS1804 digital potentiometers (by Maxim). I needed to configure some of them to default to the 0 location on power up and others to default to the mid-point resistance. So I have been using GCBasic to try and write a simple program for a PIC16F628A to automatically program these chips to their default location. I was trying to use the A/D converter (AN0) to find the midpoint and when the midpoint is found program the wiper to that location. Below I have included my code and the error I get when compiling. I have tried commenting out the line given in the a-d.h file and by removing that line I am able to compile the program. However the micro-controller will not work as I want it to. An ideas as to what is causing this error would be great!
'Hardware Specs
#chip 16F628A, 4
#config MCLRE = ON, OSC = INTOSC_OSC_NOCLKOUT, WDT=OFF
'Define I/O
#define BUSY PORTB.0 'Turns on Red LED
#define DONE PORTB.1 'Turns on Green LED
#define CS PORTB.2 'Chip Select
#define INC PORTB.3 'INC Command
#define UND PORTB.4 '(H)Up or (L)Down
#define MODE PORTB.5 'High is for volume, Low is for balance/tone
'Define I/O direction
dir PORTA.0 IN 'Analog to Digital Converter
dir BUSY OUT 'Turns on Red LED
dir DONE OUT 'Turns on Green LED
dir CS OUT 'Chip Select
dir INC OUT 'INC Command
dir UND OUT '(H)Up or (L)Down
dir MODE IN 'High is for volume, Low is for balance/tone
'Set Initial State
set BUSY ON
set DONE OFF
set CS OFF
set INC ON
set UND OFF
wait 50 10us
FOR LoopCounter = 1 to 110
set INC OFF
wait 50 10us
set INC ON
NEXT
IF MODE ON THEN GOTO EndProg
IF MODE OFF THEN
set UND ON
FOR LoopCounter = 1 to 110
set INC OFF
wait 50 10us
set INC ON
wait 50 10us
IF ReadAD10(AN0) > 511 THEN
set CS ON
wait 50 10us
GOTO EndProg
END IF
NEXT
END IF
EndProg:
'Set Final State
set BUSY OFF
set DONE ON
GOTO EndProg
Error:
a-d.h (457): Error: Incorrect parameters in Set, expected: Set variable.bit status
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well unfortunately a GCBasic reserved variable has been guessed in the #defines. Starting with BUSY, DONE, CS ….and try renaming till compilation is successful.
Kent
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the quick reply! I tried what you suggested and have renamed each of the variables in the defines. However, I am still getting the same error. I also tried a bit more debugging and I found that if I comment out the line that reads:
IF ReadAD10(AN0) > 511 THEN
I can get it to compile. Is there anything else I am missing that would cause these problems? The error still reads:
a-d.h (457): Error: Incorrect parameters in Set, expected: Set variable.bit status
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello everyone,
I am building a set of stereo controls and am using a lot of DS1804 digital potentiometers (by Maxim). I needed to configure some of them to default to the 0 location on power up and others to default to the mid-point resistance. So I have been using GCBasic to try and write a simple program for a PIC16F628A to automatically program these chips to their default location. I was trying to use the A/D converter (AN0) to find the midpoint and when the midpoint is found program the wiper to that location. Below I have included my code and the error I get when compiling. I have tried commenting out the line given in the a-d.h file and by removing that line I am able to compile the program. However the micro-controller will not work as I want it to. An ideas as to what is causing this error would be great!
Error:
a-d.h (457): Error: Incorrect parameters in Set, expected: Set variable.bit status
Well unfortunately a GCBasic reserved variable has been guessed in the #defines. Starting with BUSY, DONE, CS ….and try renaming till compilation is successful.
Kent
Thanks for the quick reply! I tried what you suggested and have renamed each of the variables in the defines. However, I am still getting the same error. I also tried a bit more debugging and I found that if I comment out the line that reads:
I can get it to compile. Is there anything else I am missing that would cause these problems? The error still reads:
a-d.h (457): Error: Incorrect parameters in Set, expected: Set variable.bit status
Ah…. the old gray matter isn't what it used to be. The 16f628a family does not have an a-d module.
Kent
Ah, that is correct. I must have been using another chip last time I used the A/D Converter. Thanks for the help!