PDA

View Full Version : Can someone help me identify why this simple program won't compile?



JosephM
- 20th April 2013, 23:38
clear
DEFINE OSC 4
DEFINE LCD_DREG PORTD
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTE
DEFINE LCD_RSIT 0
DEFINE LCD_EREG PORTE
DEFINE LCD_EBIT 1
(It stops here with a syntax error on this > ) LOW PORTE.2
(I have tried several other methods from the book that would all set port E, pin 2 to low, but for the life of me, I don't know what is going wrong. It loos so simple. I have the newest compiler, and I am trying to teach myself with a breadboard, and some book learning. Since the circuit isn't part of the problem, or even part of the question, this has to be about the syntax. I took this example code directly from a book by Harprit Singh Sandhu. I love his books, and the way he writes, and own a few of them. I considered that his book may be based on dated code, so I looked through the compiler manual and tried other ways to turn pin2 of PortE low. The compiler doesn't like anything I put place of Low PortE.2 It looks too simple, and I just don't get it, so you can imagine that I feel very ignorant to have to ask. The rest of the code follows, and maybe that will also generate syntax errors. What is the problem. Insults are Ok, I deserve them, but please make them constructive insults. :)

TRISD = %00000000
TRISE = %00000000
ADCON1 = %00000111

PAUSE 500

LCDOUT $FE, 1
LCDOUT "NOW IS THE TIME FOR"
LCDOUT $FE, $C0
LCDOUT "A CUP OF PEA SOUP"
END

Demon
- 20th April 2013, 23:52
What PIC, PBP version, ASM version?

Can you post all your entire code?

Have you tried just blinking an LED on port e.2?

Robert

JosephM
- 21st April 2013, 00:09
The PIC that this would be loaded to, if it ever got tested would be 16F877a

I have Microcode Studio 5.0.0.3 Compiler 3.0.6.3 and whatever assembler came down when I downloaded this all together.
If the ASM version is still important, you will have to direct me to where I find that bit of information.


This code sample is complete, but if it does not look complete, that may be the problem. I took the code from the book to test the LCD.
Thanks, Joe

HenrikOlsson
- 21st April 2013, 00:31
Hi,
Make sure you select the correct target device in the drop down list in MicroCode Studio before compiling.
If you're compiling for a chip which doesn't have a PortE (for example) then the compiler doesn't know what to do with the command LOW PortE.2 so it throws a Syntax Error.

I've tried your code here, compiling ot for 16F877A, and it compiles without any errors.

/Henrik.

JosephM
- 21st April 2013, 00:32
OK, your questions led me back to my program. I previously used another product that started each project with a config window, the processor, and chip configuration settings were in it. I realized that I did not have the same in this software, and once I set the processor correctly, the compiler compiled fine. That made sense to me, the commands were easy, and I had to be referencing a port that did not exist, which it did not in the default chip that was selected.

Thanks again, your questions led to my answers.

andywpg
- 21st April 2013, 02:10
Guess I should read ALL the posts - answered

JosephM
- 21st April 2013, 15:47
But your willingness to help is deeply appreciated anyway.
Guess I should read ALL the posts - answered