Tag Archives: CCS

An Interrupt Using an Input Pin on a PIC16F690 CCS C

This is just a short post on how I used an interrupt to make my Pickit 2 cycle through the LEDs. This is a very simple program, and sadly I tried this once before and it didn’t work. I did a little research and found that I didn’t enable the correct interrupts.  This experiment is just one of a few that may need to take place to design my POV for my CCS compiler. I have a Picaxe POV, but I want high brightness LEDs and it to be in C. I like projects, and this one (POV)  is going to be a little bit different than the Picaxe one. Enjoy the journey in developing my next toy.
Continue reading

Part 2: Going to Sleep(); An Interrupt Using an Input Pin on a PIC16F690 CCS C

This is part two of the POV design. I added a sleep function to this program. It counts up to 14. Once it hits 15 it goes to sleep, only to be awakened by MCLR and starting from the beginning of the program. Please enjoy.

#include <16f690.h>
#fuses intrc_io,mclr,put,nobrownout,nowdt
#use delay(clock=31000) //clock set to oscillator frequency
int count=0;

#INT_RB //this is the interrupt
void interruptMe(void) { count++; delay_ms(250); }

void main(void)
setup_oscillator(osc_31khz); //This uses less current than 4MHz
enable_interrupts(INT_RB7); //a change on RB7 triggers interrupt

while (1)   {  output_c(count);
if (count==0x0f)
output_a(0×00); output_b(0×00); output_c(0×00); //set all outputs to ground
sleep(); //should only wake up after MCLR
}  }  }

CCS C and Microchip PWM – Pulse Width Modulation

Tonight I was wondering why my PWM wasn’t working. It took me a while to figure it out, but I have it working.

Start with your C file with your normal #include and #fuses. Inside your main function you’ll use 4 built in functions and the super loop While statement. That is it! I wired a high brightness LED to pin 5 of the PIC16F690 on the Pickit 2.
Continue reading

CCS C and Microchip ADC – Analog Input

Last night I was messing around with some stuff just for experimentation’s sake. I might use this in my Datalogger though, so I thought I would explore. I’m using the Pickit 2 to do some experiments on and learn new code. Here’s what I’ve discovered.

Using a potentiometer to trigger events:

In digital inputs, a high (1) is close to 5 volts, and a low (0) is close to ground. That’s all you get. Analog inputs are capable of many intermediate values ranging from either 0 – 255, or more depending on what chip you are using. I’m using the PIC16F690, and it has an 8-bit ADC. In this case ground will return 0×00 (0) and vdd will return 0xff (255).

#include <16f690.h>
#fuses intrc_io, nowdt, nobrownout, put
#use delay(clock=4000000)

void main(void)
unsigned int adcByte;
setup_adc(adc_clock_internal); //The ADC uses a clock to work
setup_adc_ports(sAN0); //pin 19 ADC0
set_adc_channel(0); //This ADC0 is channel 0

while (1) //stay in this loop until reset
adcByte=read_adc(); //read_adc() return an 8-bit variable
/*I’m using the byte returned as the delay for an LED */
output_high(PIN_C5); delay_ms(adcByte);
output_low(PIN_C5); delay_ms(adcByte);


The SHT11 Temperature Probe Lives!!!

I combined my LCD and temp probe files into one and compiled…and (revised and compiled)*(at least 20 times)!  (revised and compiled)*(at least 20 times)=a long night. I started working on this from 3 to 4pm. Then I picked back up at 10pm and I finally had it working by 2am. I now have a temperature, humidity and dewpoint reading. The SHT11 (from eBay or Parallax) is a great little item once you get a program written for it. Since I like to use Microchip and CCS C, I had to write a program, but I used the Basic Stamp examples for guidance.
Continue reading