Author Topic: Programming the PIC12F863 in C  (Read 2481 times)

Offline Hippijoebob

  • ½ Pint
  • *
  • Posts: 32
  • Post quality +1/-0
Programming the PIC12F863 in C
« on: June 23, 2011, 04:23:00 PM »
I need help with programming my pic12f863 in C.  I am using CCS's C Compiler through MPLAB witha PICKit 2.  The question I have is how do i have the rapid fire started and then pulsed through the triggers and then stopping when you stop pulling the trigger.  Would a flowchart like this work

Check for input using while function thats equal to 1  ->  output high for 1 ms -> start 1 ms delay loop already in program for as many times as specified -> back to top

While this general idea work?  I hopw you can understand what I mean  Thanks

Offline hyper999

  • Acidmods Alumni
  • Millennium Poster
  • *
  • Posts: 1158
  • Post quality +544/-3
  • Research and Development
Re: Programming the PIC12F863 in C
« Reply #1 on: June 24, 2011, 08:13:45 AM »
You are best off setting up a timer interrupt for your pulse timing, say 1ms, then setup software counters for the speed.

For basic RF you don't need to read the triggers ever, just switch the pin between tristated and, high for matrix (needs a 330ohm resistor between the trigger and the PIC) or low for CG (no resistor needed), this will mean you only get RF when the trigger is pulled.

So,
Interrupt
Decrement counter -> counter equals 0? -YES> Reload Counter and flip the pin state -> Return
                                                                 -NO> Return

Main Program
Here you can do things like read buttons for mode changes etc

A good place to look at code structure is Hazer's BMU codes (can be found here on AM, just search), they are written in ASM however even if you do not know asm the comments are very informative.

Offline Hippijoebob

  • ½ Pint
  • *
  • Posts: 32
  • Post quality +1/-0
Re: Programming the PIC12F863 in C
« Reply #2 on: June 26, 2011, 09:18:05 PM »
Thanks for the reply.  You kinda said what I thought and confirmed it.  Thanks again.

 

SMF spam blocked by CleanTalk
SimplePortal 2.3.5 © 2008-2012, SimplePortal