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

output_high(int16 a) doesn't work

 
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 Jul 09, 2012 4:28 pm     Reply with quote

It's a bug and you need to report it to CCS support. Maybe they can fix it
in the next version.

In the code below, I've written two macros to replace the output_high()
and output_low() functions. But be aware that these seemingly small
macros will expand to a large and time-consuming amount of ASM code.
But so do the built-in CCS functions. If you want speed, you should not
use variables to pass the pin numbers.
Code:

#include <16F1947.h>
#fuses INTRC_IO,NOWDT,BROWNOUT,PUT,NOVCAP
#use delay(clock=8M)
#use rs232(baud=9600, UART1, ERRORS)
 
int16 io_port;
int8 bitmask;
int8 const bitmask_table[] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};

#define output_high(ccs_pin)           \
io_port = ccs_pin >> 3;                \
bitmask = bitmask_table[ccs_pin & 7];  \
*(io_port + 0x80) &= ~bitmask;         \
*io_port |= bitmask;                   


#define output_low(ccs_pin)            \
io_port = ccs_pin >> 3;                \
bitmask = bitmask_table[ccs_pin & 7];  \
*(io_port + 0x80) &= ~bitmask;         \
 *io_port &= ~bitmask;                     



//====================================
void main()
{
int16 my_pin;

my_pin = PIN_G4;
output_high(my_pin);

output_low(my_pin);

while(1);
}
 
cashworth



Joined: 06 Jul 2012
Posts: 3

View user's profile Send private message Visit poster's website

PostPosted: Mon Jul 09, 2012 4:52 pm     Reply with quote

I just reported the bug. Your workaround is fine for my application. Thanks much!!
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