Mithun_K_Das
Advanced Member level 3
- Joined
- Apr 24, 2010
- Messages
- 899
- Helped
- 24
- Reputation
- 48
- Reaction score
- 26
- Trophy points
- 1,318
- Location
- Dhaka, Bangladesh, Bangladesh
- Activity points
- 8,253
Error in wave inverter code with PIC16F73
I was trying to develop a simple sine wave inverter using PIC16F73 MCU.
Compiler: mikroC pro for PIC v7.6.0
Simulator: Proteus 8.9
Code:
I was simulating in proteus. Still not developed in hardware.
This code is working fine in simulation:
Problem is when I'm declearing the sine table as Const proteus can't simulate it, shows:
Can anyone tell me whats wrong here?
I was trying to develop a simple sine wave inverter using PIC16F73 MCU.
Compiler: mikroC pro for PIC v7.6.0
Simulator: Proteus 8.9
Code:
Code:
//sine wave generation using PIC16F73 test
//Crystal: 20MHz.
unsigned int sin_table[32]={0, 25, 49, 73, 96, 118, 139, 159, 177, 193, 208, 220, 231, 239, 245, 249, 250, 249, 245, 239, 231, 220, 208, 193, 177, 159, 139, 118, 96, 73, 49, 25};
int duty=0;
bit alt;
void Interrupt() iv 0x0004 ics ICS_AUTO
{
if (TMR2IF_bit == 1)
{
duty++;
if(duty>32)
{
duty=0;
alt=~alt;
}
if(alt)
{
CCPR1L = sin_table[duty];
CCPR2L=0;
RC0_bit=1;
RC3_bit=0;
}
else
{
CCPR2L = sin_table[duty];
CCPR1L=0;
RC0_bit=0;
RC3_bit=1;
}
TMR2IF_bit = 0;
}
}
void main()
{
TRISC = 0x00;
PR2 = 249;
CCP1CON = 0x4C;
CCP2CON = 0x4C;
TMR2IF_bit = 0;
T2CON = 0x14;
TMR2IF_bit = 0;
TRISC = 0;
TMR2IE_bit = 1;
GIE_bit = 1;
PEIE_bit = 1;
while(1)
{
}
}
//
I was simulating in proteus. Still not developed in hardware.
This code is working fine in simulation:
Problem is when I'm declearing the sine table as Const proteus can't simulate it, shows:
Can anyone tell me whats wrong here?
Last edited: