Skip to content

Instantly share code, notes, and snippets.

@gresan-gits
Created February 2, 2020 10:33
Show Gist options
  • Save gresan-gits/e2276a5686310d6d0a63bdd04311ab9b to your computer and use it in GitHub Desktop.
Save gresan-gits/e2276a5686310d6d0a63bdd04311ab9b to your computer and use it in GitHub Desktop.
CCS C IO
#include <main.h>
#include <output.c>
int8 in;
void main ()
{
output_float (pin_D7) ;
//Example blinking LED program
while (true)
{
//Doc gia trij vao 1 chan roi xuat led
// in=input(PIN_C0);
//Doc gia tri ca port
// in=input_c();
// output_b(in);
//Doc gia tri 1 nut bam va sang ca port
// in=input(PIN_C0);
// if(in==1)
// {
// output_b(0b0000101010);
// }
// else
// {
// output_b(0x10);//0x00=0b000000000
// }
output_bit(PIN_C6,0);
delay_ms(500);
output_bit(PIN_C6,1);
delay_ms(500);
}
}
#include <18F4520.h>
#device adc=16
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#use delay(clock=20000000)
#define LED PIN_C3
#define DELAY 500
void output(void)
{
output_low (PIN_C3);
output_b (0xff); //255//0b11111111: 0x: xuat gia tri HEX
// output_d (0b00000111) ;
output_high (PIN_D0);
output_high (PIN_D1);
output_high (PIN_D2);
output_bit (PIN_D7, 1) ;
output_bit (PIN_D6, 0) ;
//0b: ma nhi pha
delay_ms (DELAY);
output_high (PIN_C3);
output_b (0b00000000) ;
output_bit (PIN_D7, 0) ;
delay_ms (DELAY);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment