Skip to content

Instantly share code, notes, and snippets.

@hayview
hayview / main.c
Created December 27, 2015 02:01
timer0 interrupt setting
#include <p18f4553.h>
#include "task_led.h"
#include "timer0.h"
//******************************************************************************
// CONFIG
//******************************************************************************
#pragma config PLLDIV = 5 // (20 MHz crystal on PICDEM FS USB board)
#pragma config CPUDIV = OSC1_PLL2
#pragma config USBDIV = 2 // Clock source from 96MHz PLL/2
@hayview
hayview / 1wire.c
Created October 3, 2015 03:24
USB-CDC and HD44780 and DS18B20
#include "1wire.h"
void OW_DriveLow(void);
void OW_DriveHigh(void);
void OW_WriteBit(unsigned char OW_data_bit);
void OW_DriveLow(void)
{
OW_PIN_DIRECTION=OW_OUTPUT;
OW_WRITE_PIN=0;
@hayview
hayview / delay.h
Created July 24, 2015 14:19
hd44780 lcd routine with custom character function
#ifndef DELAY_H_
#define DELAY_H_
#include <delays.h>
#define delay1MicroSecond() {Delay10TCYx(1); Delay1TCY(); Delay1TCY();}
#define delay5MicroSecond() Delay10TCYx(6)
#define delay10MicroSecond() Delay10TCYx(12)
#define delay50MicroSecond() Delay10TCYx(60)
#define delay100MicroSecond() Delay100TCYx(12)
#ifndef DELAY_H_
#define DELAY_H_
#include <delays.h>
#define delay1MicroSecond() {Delay10TCYx(1); Delay1TCY(); Delay1TCY();}
#define delay5MicroSecond() Delay10TCYx(6)
#define delay10MicroSecond() Delay10TCYx(12)
#define delay50MicroSecond() Delay10TCYx(60)
#define delay100MicroSecond() Delay100TCYx(12)
@hayview
hayview / delay.h
Created June 12, 2015 15:24
delay routine for c18 (tested with blinking the led)
#ifndef DELAY_H_
#define DELAY_H_
#include <delays.h>
#define delay1MicroSecond() {Delay10TCYx(1); Delay1TCY(); Delay1TCY();}
#define delay5MicroSecond() Delay10TCYx(6)
#define delay10MicroSecond() Delay10TCYx(12)
#define delay50MicroSecond() Delay10TCYx(60)
#define delay100MicroSecond() Delay100TCYx(12)
@hayview
hayview / HardwareProfile - PIC SK40C.h
Created March 24, 2015 01:52
SK40C pic development kit hardware profile
/********************************************************************
FileName: HardwareProfile - PIC SK40C.h
Dependencies: See INCLUDES section
Processor: PIC18 USB Microcontrollers
Hardware: PIC SK40C
Compiler: Microchip C18
Company: CYTAN.
********************************************************************
File Description:
@hayview
hayview / delay.c
Created January 29, 2015 05:49
for stepper motor control
#include "delay.h"
void delayMicroSecond (unsigned int time)
{
while (time--)
{
_delay_cycles(MICRO_SECOND);
}
}
@hayview
hayview / delay.c
Created January 29, 2015 05:47
for stepper motor control
#include "delay.h"
void delayMicroSecond (unsigned int time)
{
while (time--)
{
_delay_cycles(MICRO_SECOND);
}
}
@hayview
hayview / delay.c
Created January 29, 2015 05:44
for stepper motor control
#include "delay.h"
void delayMicroSecond (unsigned int time)
{
while (time--)
{
_delay_cycles(MICRO_SECOND);
}
}
#include <msp430.h>
/*
* main.c
*/
#define DIR_PIN 0x01
#define STEP_PIN 0x02
#define FORWARD 0x01