| View previous topic :: View next topic |
| Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
 |
Sid2286
Joined: 12 Aug 2010 Posts: 119
|
|
Posted: Mon Apr 04, 2011 12:24 pm |
|
|
| Complier ver. 4.093 |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Apr 04, 2011 1:02 pm |
|
|
That's an old version and it's buggy. This demo program shows how to
fix the bug with the initial setup of the analog ports.
| Code: |
#include <16F1937.h>
#fuses INTRC_IO,NOWDT,NOBROWNOUT,NOPUT
#use delay(clock=4000000)
void make_all_pins_digital(void)
{
#byte ANSELA = getenv("SFR:ANSELA")
#byte ANSELB = getenv("SFR:ANSELB")
#byte ANSELD = getenv("SFR:ANSELD")
#byte ANSELE = getenv("SFR:ANSELE")
ANSELA = 0;
ANSELB = 0;
ANSELD = 0;
ANSELE = 0;
}
//===========================
void main()
{
make_all_pins_digital(); // Fix bug in vs. 4.093
while(1)
{
if(input(PIN_A1)) // Read pin A1
output_high(PIN_B0); // Set B0 to same value
else
output_low(PIN_B0);
}
} |
|
|
 |
Sid2286
Joined: 12 Aug 2010 Posts: 119
|
|
Posted: Mon Apr 04, 2011 6:53 pm |
|
|
Thanks PCM!
I will try the above code and get back! |
|
 |
Sid2286
Joined: 12 Aug 2010 Posts: 119
|
|
Posted: Mon Apr 04, 2011 11:29 pm |
|
|
Thanks PCM
The trouble is sorted out!
Sid |
|
 |
Sid2286
Joined: 12 Aug 2010 Posts: 119
|
|
Posted: Tue Apr 05, 2011 5:42 am |
|
|
I guess the complier is full of bugs :(
when I try to compile with | Code: | | #include <16F1937.h> | it complies properly. Now I change the header file with | Code: | | #include <16F1936.h> | there are plenty of errors.
I did comment the following:-
| Code: |
void make_all_pins_digital(void)
{
#byte ANSELA = getenv("SFR:ANSELA")
#byte ANSELB = getenv("SFR:ANSELB")
//#byte ANSELD = getenv("SFR:ANSELD")
//#byte ANSELE = getenv("SFR:ANSELE")
ANSELA = 0;
ANSELB = 0;
//ANSELD = 0;
//ANSELE = 0;
} |
but still not working :(
what should I be doing? |
|
 |
dyeatman
Joined: 06 Sep 2003 Posts: 1985 Location: Norman, OK
|
|
Posted: Tue Apr 05, 2011 6:15 am |
|
|
I was able to compile PCMs code for either MCU with no changes.
What code are you using? What errors are you getting? _________________ Google and Forum Search are some of your best tools |
|
 |
Sid2286
Joined: 12 Aug 2010 Posts: 119
|
|
Posted: Tue Apr 05, 2011 6:34 am |
|
|
my code along with the necessary changes as specified by PCM is as follows:-
| Code: |
#include <16f1936.h>
#device ICD=TRUE
#fuses HS,NOLVP
#use delay (clock=40000000)
void make_all_pins_digital(void)
{
#byte ANSELA = getenv("SFR:ANSELA")
#byte ANSELB = getenv("SFR:ANSELB")
#byte ANSELD = getenv("SFR:ANSELD")
#byte ANSELE = getenv("SFR:ANSELE")
ANSELA = 0;
ANSELB = 0;
ANSELD = 0;
ANSELE = 0;
}
LED_ON()
{
output_high(PIN_B5);
output_high(PIN_B6);
output_high(PIN_B7);
delay_ms(1000);
output_low(Pin_B5);
output_low(Pin_B6);
output_low(Pin_B7);
delay_ms(1000);
}
void main()
{
make_all_pins_digital();
while(1)
{
if(input(pin_A1)==1)
{
while(1)
{
LED_ON();
if(input(pin_A1)==0)
{
output_low(Pin_B7);
output_low(Pin_B5);
output_low(Pin_B6);
break;
}
}
}
}
} |
Interesting part is when i complier it for 16F1937 and burn it on 16F1936 it still works....though I achieve what I want. its strange! :( |
|
 |
dyeatman
Joined: 06 Sep 2003 Posts: 1985 Location: Norman, OK
|
|
Posted: Tue Apr 05, 2011 6:51 am |
|
|
Your code compiles fine with a few warnings but no errors for both MCUs.
What errors are you seeing? _________________ Google and Forum Search are some of your best tools |
|
 |
Sid2286
Joined: 12 Aug 2010 Posts: 119
|
|
Posted: Tue Apr 05, 2011 7:06 am |
|
|
The above code is getting complied for 16F1937.h, but giving plenty of errors for 16F1936.h I'm using a ver. of 4.093
the Error are as follows:
Expecting a declaration
Expecting a (
the errors are full of the above two errors. |
|
 |
dyeatman
Joined: 06 Sep 2003 Posts: 1985 Location: Norman, OK
|
|
Posted: Tue Apr 05, 2011 4:53 pm |
|
|
The header file you sent me had duplicate defines in it for some reason.
I sent you a corrected version that compiles with no errors for me. Use it
with the EXACT code posted by PCM to see if compiles without errors. _________________ Google and Forum Search are some of your best tools |
|
 |
Sid2286
Joined: 12 Aug 2010 Posts: 119
|
|
Posted: Wed Apr 06, 2011 10:51 pm |
|
|
The new header file which you mailed me isnt working either, I guess its the complier isnt compatible with it.
Need some help :( |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 20159
|
|
Posted: Thu Apr 07, 2011 1:52 am |
|
|
Double check your 'project' settings (assuming you are using the windowed compiler). The code compiles on 4.093, _without errors_. What you are describing, often happens, when the project was originally built with an older compiler (say 4.07x), and then upgraded to a latter compiler in a different directory. The project 'remembers' where the old include files were, and keeps loading the ones for the wrong compiler. Hence errors.....
Best Wishes |
|
 |
|