CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Port A as an Input not working
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 04, 2011 11:39 am     Reply with quote

Post your full compiler version.

Examples of compiler version numbers:
http://www.ccsinfo.com/devices.php?page=versioninfo
Sid2286



Joined: 12 Aug 2010
Posts: 119

View user's profile Send private message

PostPosted: Mon Apr 04, 2011 12:24 pm     Reply with quote

Complier ver. 4.093
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 04, 2011 1:02 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Apr 04, 2011 6:53 pm     Reply with quote

Thanks PCM!
I will try the above code and get back!
Sid2286



Joined: 12 Aug 2010
Posts: 119

View user's profile Send private message

PostPosted: Mon Apr 04, 2011 11:29 pm     Reply with quote

Thanks PCM

The trouble is sorted out!

Sid
Sid2286



Joined: 12 Aug 2010
Posts: 119

View user's profile Send private message

PostPosted: Tue Apr 05, 2011 5:42 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Apr 05, 2011 6:15 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Apr 05, 2011 6:34 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Apr 05, 2011 6:51 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Apr 05, 2011 7:06 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Apr 05, 2011 4:53 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Apr 06, 2011 10:51 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Apr 07, 2011 1:52 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group