Anuradha1
Member level 2
Hello all,
i have some short int variables, T3H and T3L.
They are assigned to relavant values by pic16f877a.
These values are sent to a PC using Uart.
The program I have written in mikroC is compiled successfully.
It was simulated well in PICsimulator.
But when loaded to the pic and run, the hyperterminal didnot gave me the results.
I have attached the program herewith.
Can some one help me to solve the problem
Thanks
i have some short int variables, T3H and T3L.
They are assigned to relavant values by pic16f877a.
These values are sent to a PC using Uart.
The program I have written in mikroC is compiled successfully.
It was simulated well in PICsimulator.
But when loaded to the pic and run, the hyperterminal didnot gave me the results.
I have attached the program herewith.
Code:
/*Calculate PWM using CCP modules */
//start timer after capturing rising edge. so no need of sustraction function
//Transmit directly captured width and time period values via uart
//uart transmission delay loop:Eventhough i have introduce a delay within the program, simulator doesnot adhere to my delay :(
//Still uart works on Delay specified under option Uart Transmission/Receive delay.
//Precesion is lesser than capturing the values with substraction function
unsigned short int T2L,T2H,T3L,T3H,x,i,Count;
void Loop_rise();
void Loop_rise1();
void Loop_fall();
void Transmit(unsigned short int i);
void main()
{
CCP1CON = 0x00;
INTCON =0x00;
TRISC.B2 =1;
PIE1 =0x00; //disable peripheral interrupts
while(1)
{
//TMR1H=0;
//TMR1L=0; /*These give wrong readings
PIR1=0; //PIR1 register contains individual flag bits for periphiral interrupts
CCP1CON =0x05; //capture rising edge
//calculating header
if(Count <10)
{
Count++;
}
else
{
Count =0;
}
Loop_rise1();
Transmit(Count);
Loop_fall();
T2L= CCPR1L;
T2H= CCPR1H;
Transmit(T2H);
Transmit(T2L);
Loop_rise();
T3L= CCPR1L;
T3H= CCPR1H;
Transmit(T3H);
Transmit(T3L);
}
}
void Loop_rise1()
{
x=0;
while (x==0)
{
if (CCP1IF_bit == 1)
{
TMR1H=0;
TMR1L=0;
T1CON =1; //start timer1
CCP1CON =0x04;
CCP1IF_bit =0;
x=1;
}
}
}
void Loop_rise()
{
x=0;
while (x==0)
{
if (CCP1IF_bit == 1)
{
CCP1CON =0x04;
CCP1IF_bit =0;
x=1;
}
}
}
void Loop_fall()
{
x=0;
while (x==0)
{
if (CCP1IF_bit == 1)
{
CCP1CON =0x05;
CCP1IF_bit =0;
x=1;
}
}
}
// UART transmission
void Transmit(unsigned short int i)
{
Uart1_Init(9600);
Uart1_Write(i);
Delay_us(100);
}
Can some one help me to solve the problem
Thanks