tari
Joined: 14 Jun 2014 Posts: 1
|
ccs c pic16f88 port blink |
Posted: Tue Nov 15, 2016 12:48 pm |
|
|
Code: | /* port_blink.c
By Tarilayefa Edward
[email protected]
Date: 15/11/2016.
A simple port blinking code that flashes port a and b on/off
at the rate of t1 milliseconds.
Compiler: PCWHD Compiler v5.008
PIC16F88 used.
*/
#include <16F88.h> //include pic16f88 header file
void main(void) {
//#byte OSCCON = 0x60 //4MHz 0scillator
#byte OSCCON = OSC_4MHZ //4MHz 0scillator
//#byte OSCCON = 0b01101000 //4MHz 0scillator
//#Fuses NOWDT,WDT,PUT,NOPUT,LP,XT,HS,EC_IO,INTRC_IO,INTRC,RC_IO,RC
#Fuses INTRC_IO //internal osc used with a6, a7 as digital pins
#use delay(clock=4000000) //4mhZ CLOCK SPEED
setup_adc(ADC_OFF);
set_tris_a( 0x00 ); //SET port a to output
OUTPUT_a(0x00); //turn off porta
set_tris_b( 0x00 ); //SET port b to output
OUTPUT_b(0x00); //turn off portB
int16 t1; //declare t1 as 16bit variable (0 to 65535)
t1 = 1000; //t1 in milliseconds
While(TRUE) { //main loop
//OUTPUT_HIGH(PIN_B0); //turn on portb.0
OUTPUT_a(0xff); //turn on porta
output_b(0xff); //turn on portb
DELAY_MS(t1); //delay for time t1 ms
//OUTPUT_LOW(PIN_B0); //turn off portb.0
OUTPUT_a(0x00); //turn off porta
output_b(0x00); //turn off portb
DELAY_MS(t1);
}
} |
|
|