PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Jul 09, 2012 4:28 pm |
|
|
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);
}
|
|
|