04-13-2021 02:51 PM
Hi all, can anyone help?
I'm trying to run a simple PWM circuit (4 button, 40%/60%/100%/stop) and I'm getting a strange error. The code was ripped off from https://www.electronicshub.org/pwm-based-dc-motor-speed-control-using-microcontroller/ and I've adapted it for 8051 Hitech C compiler. The code follows along with the 12 linking errors.
Thanks in advance.
#include<htc.h>
#define PWM_Pin P00
#define low P04
#define medium P05
#define high P06
#define off P07
void InitPWM_timer(void);
unsigned char PWM = 0;
unsigned int temp = 0;
char a=1;
int main(void)
{
low=1;
medium=1;
high=1;
off=1;
PWM_Pin=0;
InitPWM_timer();
while(1)
{
if(low==0)
{
PWM=102;
a=0;
}
else if(medium==0)
{
PWM=153;
a=0;
}
else if(high==0)
{
PWM=255;
a=0;
}
else if(off==0)
{
a=1;
PWM_Pin=0;
}
}
}
void InitPWM_timer (void)
{
TMOD &= 0xF0;
TMOD |= 0x01;
TH0 = 0x00;
TL0 = 0x00;
ET0 = 1;
EA = 1;
TR0 = 1;
}
void interrupt Timer0_ISR (void)
{
TR0 = 0;
if(PWM_Pin==1 && a==0)
{
PWM_Pin = 0;
temp = (255-PWM);
TH0 = 0xFF;
TL0 = 0xFF - temp&0xFF;
}
else if(PWM_Pin==0 && a==0)
{
PWM_Pin = 1;
temp = PWM;
TH0 = 0xFF;
TL0 = 0xFF - temp&0xFF;
}
TF0 = 0;
TR0 = 1;
}
Multisim - 13 April 2021, 20:35:50
--------------------Building: Project: PWM_Motor_Controller---------------------
Note: -E compiler option was not present. This option has been added to the compiler build command temporarily.
Note: -O compiler option was not present. This option has been added to the compiler build command temporarily.
Compiler results: 0 - Errors, 0 - Warnings
Linking...
Error: : 0 fixup overflow referencing psect data (location 0x1D (0x3+26), size 1, value 0x100)
Error: : 0 fixup overflow referencing psect data (location 0x2C (0x3+41), size 1, value 0x100)
Error: : 0 fixup overflow referencing psect data (location 0x3B (0x3+56), size 1, value 0x100)
Error: : 0 fixup overflow referencing psect data (location 0x47 (0x3+68), size 1, value 0x100)
Error: : 0 fixup overflow referencing psect data (location 0x71 (0x3+110), size 1, value 0x100)
Error: : 0 fixup overflow referencing psect data (location 0x9F (0x3+156), size 1, value 0x100)
Error: : 0 fixup overflow in expression (location 0x23 (0x23+0), size 1, value 0x100)
Error: : 0 fixup overflow in expression (location 0x23 (0x23+0), size 1, value 0x100)
Error: : 0 fixup overflow in expression (location 0x23 (0x23+0), size 1, value 0x100)
Error: : 0 fixup overflow in expression (location 0x23 (0x23+0), size 1, value 0x100)
Error: : 0 fixup overflow in expression (location 0x23 (0x23+0), size 1, value 0x100)
Error: : 0 fixup overflow in expression (location 0x23 (0x23+0), size 1, value 0x100)
Linker results: 12 - Errors, 0 - Warnings