saifbd3344
Junior Member level 3
- Joined
- Apr 20, 2014
- Messages
- 29
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Location
- Dhaka
- Activity points
- 163
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
no browse from C:\Program Files (x86)\Microchip\MPLAB C30\src\peripheral_30F_24H_33F\include
#include "delay.h"
#include <delay.h>
#include <htc.h>
//#include "delay.h"
#define _XTAL_FREQ 8000000
void main(void){
TRISB=0X00;
PORTB=0x00;
while(1)
{
PORTB=0xFF;
__delay_ms(100);
PORTB=0x00;
__delay_ms(100);
}
}
/*
* Delay functions
* See delay.h for details
*
* Make sure this code is compiled with full optimization!!!
*/
#include "delay.h"
void
DelayMs(unsigned char cnt) {
unsigned char i;
while (cnt--) {
i=4;
while(i--) {
DelayUs(uS_CNT); /* Adjust for error */
} ;
} ;
}
/*
* Delay functions for HI-TECH C on the PIC18
*
* Functions available:
* DelayUs(x) Delay specified number of microseconds
* DelayMs(x) Delay specified number of milliseconds
*
* Note that there are range limits:
* - on small values of x (i.e. x<10), the delay becomes less
* accurate. DelayUs is accurate with xtal frequencies in the
* range of 4-16MHZ, where x must not exceed 255.
* For xtal frequencies > 16MHz the valid range for DelayUs
* is even smaller - hence affecting DelayMs.
* To use DelayUs it is only necessary to include this file.
* To use DelayMs you must include delay.c in your project.
*
* Set the crystal frequency in the CPP predefined symbols list
* on the PICC-18 commmand line, e.g.
* picc18 -DXTAL_FREQ=4MHZ
*
* or
* picc18 -DXTAL_FREQ=100KHZ
*
* Note that this is the crystal frequency, the CPU clock is
* divided by 4.
*
* MAKE SURE this code is compiled with full optimization!!!
*/
#define MHZ *1
#ifndef XTAL_FREQ
#define XTAL_FREQ 4MHZ /* Crystal frequency in MHz */
#endif
#if XTAL_FREQ < 8MHZ
#define uS_CNT 238 /* 4x to make 1 mSec */
#endif
#if XTAL_FREQ == 8MHZ
#define uS_CNT 244
#endif
#if XTAL_FREQ > 8MHZ
#define uS_CNT 246
#endif
#define FREQ_MULT (XTAL_FREQ)/(4MHZ)
#define DelayUs(x) { unsigned char _dcnt; \
if(x>=4) _dcnt=(x*(FREQ_MULT)/2); \
else _dcnt=1; \
while(--_dcnt > 0) \
{\
asm("nop");\
asm("nop");\
continue; }\
}
extern void DelayMs(unsigned char);