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

How can i use PORTB instead of output_b()

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



Joined: 29 May 2008
Posts: 8

View user's profile Send private message

How can i use PORTB instead of output_b()
PostPosted: Tue Jun 10, 2008 6:56 am     Reply with quote

hi,

i want to use PORTB as output directly, i mean, when i write:
PORTB=1; first led of PORTB will ON.

i defined my registers in main.h:

Code:
#include <16F877A.h>

#byte PORTB = 0x06
#byte TRISB = 0x86

#byte OUTPUT = PORTB
#byte OUTPUT_DIR = TRISB


and main.c:


Code:
 
OUTPUT_DIR=0x00;
   
 while(1)
   {
   OUTPUT=0;
   delay_ms(100);
   OUTPUT=1;
   }



it compiles good. but doesnt work in simulation.
Guest








PostPosted: Tue Jun 10, 2008 7:47 am     Reply with quote

Never used the simulator,but if I was testing this on a scope I would have a delay after output=1.

regards
dyeatman



Joined: 06 Sep 2003
Posts: 1937
Location: Norman, OK

View user's profile Send private message

PostPosted: Tue Jun 10, 2008 9:30 am     Reply with quote

You can either use the Output_bit() function or #bit preprocessor directive
from page 90 of the current manual:

Quote:
#BIT

Syntax: #bit id = x.y

Elements: id is a valid C identifier,
x is a constant or a C variable,
y is a constant 0-7.

Purpose: A new C variable (one bit) is created and is placed in memory at byte x and bit
y. This is useful to gain access in C directly to a bit in the processors special
function register map. It may also be used to easily access a bit of a standard
C variable.

Examples: #bit T0IF = 0xb.2
...
T0IF = 0; // Clear Timer 0 interrupt flag


int result;
#bit result_odd = result.0
...
if (result_odd)

Example Files: ex_glint.c
Also See: #byte, #reserve, #locate, #word
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