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

PIC 16f689 Initializing Port For communication & ADC

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
yo



Joined: 22 Dec 2010
Posts: 1

View user's profile Send private message

PIC 16f689 Initializing Port For communication & ADC
PostPosted: Wed Dec 22, 2010 11:50 pm     Reply with quote

Initializing Port For communication over RS232 & ADC interface for PIC 16f689
OUTPUT_B(0x00) gives ERROR while compilation
- Undefined identifier -- OUTPUT_B
& it doesnt communicate otherwise

Code:

#separate
void port_init (void)
{

OUTPUT_A(0x00);
ANSEL=0x0C;
ANSELH=0x07;
SET_TRIS_A(0x1F);
OUTPUT_B(0x00);
SET_TRIS_B(0x30);
OUTPUT_C(0x00);
SET_TRIS_C(0xC0);
port_a_pullups(FALSE);
WPUB=0x00;
CM1C0N0=0x00;
CM2CON0=0x00;
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19554

View user's profile Send private message

PostPosted: Thu Dec 23, 2010 3:21 am     Reply with quote

Several things:
1) Why not use the CCS ADC setup functions. For 99.9% of code, there is no reason at all, to ever get involved in talking directly to registers.

2) If asking a question about an error like this, _always_ post the compiler version.

3) Have you tried compiling what you posted, with just a minimum 'header', so something like:

Code:

#include <16F689.h>
#fuses HS
#use delay(clock=8000000)

#separate
void port_init (void) {
  OUTPUT_A(0x00);
  //ANSEL=0x0C;
  //ANSELH=0x07;
  SET_TRIS_A(0x1F);
  OUTPUT_B(0x00);
  SET_TRIS_B(0x30);
  OUTPUT_C(0x00);
  SET_TRIS_C(0xC0);
  port_a_pullups(FALSE);
  //WPUB=0x00;
  //CM1C0N0=0x00;
  //CM2CON0=0x00;
}

void main(void) {
   setup_spi(FALSE);
   port_init();

    while(true) ;
}


Does it still give a problem?.

4) It is 'common' in CCS, for the actual location where a problem is reported, to have almost no relevance to the actual problem. The compiler carries on steaming through code, till an earlier problem suddenly makes something not work, and reports the problem here, rather than several lines earlier, where the actual error is. I suspect your fault is like this....

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
Page 1 of 1

 
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