e đang làm đồ án. đề tài inverter . mà có file c giờ chuyển sang hex mà nó báo tùm lum lỗi hết.
có bác nào rành về vấn đề này ko??/ thì giúp e vs. trân thành cảm ơn rất nhiều. @@@@@
chương trình nó như sau. các bác xem giúp nha
sử dụng thạnh anh 20MH
#define USE_OR_MASKS
#include <p18f1320.h>
#include "pwm.h"
#include "timers.h"
//-------------------Configuration setting------------------
* Oscillator is configured as HS
* Fail safe monitor is enabled
* watch dog timer is disabled
* Extended instruction mode is disabled
* oscillator switch over is enabled
*/
#if defined(__18F1320) //If the selected device if PIC18F4685, then
apply below settings else user will have to set
#pragma config OSC=HS, FSCM=ON, WDT=OFF, IESO=ON, LVP=OFF
#endif
void main(void)
{
char period=0x00;
unsigned char outputconfig=0,outputmode=0,config=0;
unsigned int duty_cycle=0;
unsigned int timer=0;
unsigned int i=0;
unsigned int dutyCycle_Array[40]={0x005B, 0x0053, 0x004E, 0x0048, 0x0044,
0x0040, 0x003D, 0x003C, 0x003D, 0X0040, 0x0044, 0x0048, 0x004E,
0x0055, 0x005D, 0x0065, 0x006E, 0x0078, 0x0080, 0x0089, 0x0093,
0x009B, 0x00A3, 0x00A7, 0X00AF, 0X00B2, 0X00B5, 0X00B7, 0X00B7,
0X00B5, 0X00B4, 0X00B1, 0X00AB, 0X00A6, 0X009E, 0X0097, 0X008E,
0X0086, 0X007E};
OpenTimer2(T2_PS_1_4);
//------------------Configure pwm ---------
period = 0x3C;
OpenPWM1(period); //Configure PWM module and
initialize PWM period
while(1) //observe output on CCP1 pin
{
//---------------------set duty cycle---------------------------------------------------------
for(i=0;i<40;i++)
{
SetDCPWM1(dutyCycle_Array[i]); //set the duty cycle
//-------------------set pwm output---------------------------------------------------------.
outputconfig = FULL_OUT_FWD;
outputmode = PWM_MODE_1;
SetOutputPWM1( outputconfig, outputmode); //output PWM in
respective modes
outputconfig = FULL_OUT_REV;
outputmode = PWM_MODE_3;
SetOutputPWM1( outputconfig, outputmode);
}
}
//--------------------------close pwm----------------------------------------
ClosePWM1();
}
có bác nào rành về vấn đề này ko??/ thì giúp e vs. trân thành cảm ơn rất nhiều. @@@@@
chương trình nó như sau. các bác xem giúp nha
sử dụng thạnh anh 20MH
#define USE_OR_MASKS
#include <p18f1320.h>
#include "pwm.h"
#include "timers.h"
//-------------------Configuration setting------------------
* Oscillator is configured as HS
* Fail safe monitor is enabled
* watch dog timer is disabled
* Extended instruction mode is disabled
* oscillator switch over is enabled
*/
#if defined(__18F1320) //If the selected device if PIC18F4685, then
apply below settings else user will have to set
#pragma config OSC=HS, FSCM=ON, WDT=OFF, IESO=ON, LVP=OFF
#endif
void main(void)
{
char period=0x00;
unsigned char outputconfig=0,outputmode=0,config=0;
unsigned int duty_cycle=0;
unsigned int timer=0;
unsigned int i=0;
unsigned int dutyCycle_Array[40]={0x005B, 0x0053, 0x004E, 0x0048, 0x0044,
0x0040, 0x003D, 0x003C, 0x003D, 0X0040, 0x0044, 0x0048, 0x004E,
0x0055, 0x005D, 0x0065, 0x006E, 0x0078, 0x0080, 0x0089, 0x0093,
0x009B, 0x00A3, 0x00A7, 0X00AF, 0X00B2, 0X00B5, 0X00B7, 0X00B7,
0X00B5, 0X00B4, 0X00B1, 0X00AB, 0X00A6, 0X009E, 0X0097, 0X008E,
0X0086, 0X007E};
OpenTimer2(T2_PS_1_4);
//------------------Configure pwm ---------
period = 0x3C;
OpenPWM1(period); //Configure PWM module and
initialize PWM period
while(1) //observe output on CCP1 pin
{
//---------------------set duty cycle---------------------------------------------------------
for(i=0;i<40;i++)
{
SetDCPWM1(dutyCycle_Array[i]); //set the duty cycle
//-------------------set pwm output---------------------------------------------------------.
outputconfig = FULL_OUT_FWD;
outputmode = PWM_MODE_1;
SetOutputPWM1( outputconfig, outputmode); //output PWM in
respective modes
outputconfig = FULL_OUT_REV;
outputmode = PWM_MODE_3;
SetOutputPWM1( outputconfig, outputmode);
}
}
//--------------------------close pwm----------------------------------------
ClosePWM1();
}
Comment