jelodavid 0 Posted February 28, 2005 Report Share Posted February 28, 2005 Good day to all! Please help me on defining ports on boostC..... here's sample progra: #define MODE portb,2 // set_bit(MODE); // but i got this error: Too few arguments for: set_bit Quote Link to post Share on other sites
Guest Joe Posted March 2, 2005 Report Share Posted March 2, 2005 use this: // in your header file, define variables for each pin on each port, like this: volatile bit bPin0 @ PORTA.0 volatile bit bPin1 @ PORTA.1 volatile bit bPin2 @ PORTA.2 volatile bit bPin3 @ PORTA.3 volatile bit bPin4 @ PORTA.4 volatile bit bPin5 @ PORTA.5 : : : bPin1 = 1; // turn on pin 1 bPin4 = 0; // turn off pin 4 if( bPin5 ) { // pin 5 is high } if( ! bPin0 ) { // pin 0 is low } You will also need to define the TRIS directions for the port(s) you will be using. HTH Joe Quote Link to post Share on other sites
jelodavid 0 Posted March 4, 2005 Author Report Share Posted March 4, 2005 thank you very much for the tip.... God Bless......... Quote Link to post Share on other sites
Maister 0 Posted March 4, 2005 Report Share Posted March 4, 2005 Hello! I have got one similar question. I want to write in register some Bin number.For example: I need 11111100 in register PORTB.I think that is not right(PORTB=11111100) Please tell me how can I do this? Thanks for the answers! Quote Link to post Share on other sites
Dave 0 Posted March 4, 2005 Report Share Posted March 4, 2005 Maister, Try something like this: #include <system.h> void main() { portb = 11111100b; } Regards Dave Quote Link to post Share on other sites
Maister 0 Posted March 5, 2005 Report Share Posted March 5, 2005 I tried to do that,but it doesn't work.I wrote simple program,counter from 0 to 1. Something in the program is not right.I am going to put 7segment LED display on PORTB. Please tell me where is the mistake. There is my simple program. #include <system.h> void main() { trisa= 0; //output trisb= 0; //output loop: PORTB= 11111100b; //value of PORTB. delay_s( 1 ); PORTB= 01100000b; //value of PORTB. delay_s( 1 ); goto loop; } Quote Link to post Share on other sites
Dave 0 Posted March 5, 2005 Report Share Posted March 5, 2005 Maister, tried to do that,but it doesn't work. It wasn't meant to work, just compile. you would need to add trisb = 0; to the code to set port b to output. The code below works for the PIC16F84A #include <system.h> void main() { trisb= 0; //output loop: portb= 11111100b; //value of PORTB. delay_s( 1 ); portb= 01100000b; //value of PORTB. delay_s( 1 ); goto loop; } Regards Dave Quote Link to post Share on other sites
Maister 0 Posted March 5, 2005 Report Share Posted March 5, 2005 Dave,Idon't understand you perfectly.I wrote trisb = 0; in my programe. Now I tried this code for PIC16F84a.The compiler gave me next messages: BoostC Optimizing C Compiler Version 2.0.1 Beta (for PIC16 architecture) http://www.picant.com/c2c/c.html Copyright© 2004-2005 Pavel Baranov Copyright© 2004-2005 David Hobday 7segmentni_C.pp(1): error: failure failure Exit code was 1. Removing target: 7segmentni_C.obj Failed to locate output file '7segmentni_C.obj' Done Failed Please,tell me what i did wrong. Thanks for the answers! Quote Link to post Share on other sites
djsmith1000 0 Posted March 8, 2005 Report Share Posted March 8, 2005 Another question about the port definitions: I cannot get the compiler to accept port definitions declared extern in a header file, or declared regularly in the header file or any other way, other than directly in the source file. I need to be able to have this declared globally in the header file because there are multiple source files that use this header, but it won't work. I've tried numerous things, including: .c file: volatile bit NC_0 @ PORTB, 0; .h file volatile bit NC_0 @ PORTB, 0; or extern ' ' or just declaring them in the header file, and whatever else I could think of. error just states " general error" Any reason for this? Dan Quote Link to post Share on other sites
djsmith1000 0 Posted March 8, 2005 Report Share Posted March 8, 2005 nevermind, got it. Quote Link to post Share on other sites
MotoDog 0 Posted March 16, 2005 Report Share Posted March 16, 2005 Maister, Don't you have to use lower case (portb) instead of PORTB in this example. PORTB is the fixed address of B? ??? Mike I tried to do that,but it doesn't work.I wrote simple program,counter from 0 to 1.Something in the program is not right.I am going to put 7segment LED display on PORTB. Please tell me where is the mistake. There is my simple program. #include <system.h> void main() { trisa= 0; //output trisb= 0; //output loop: PORTB= 11111100b; //value of PORTB. delay_s( 1 ); PORTB= 01100000b; //value of PORTB. delay_s( 1 ); goto loop; } <{POST_SNAPBACK}> Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.