Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Displaying hexadecimal in hyperterminal

Status
Not open for further replies.

Anuradha1

Member level 2
Joined
Nov 11, 2009
Messages
49
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
India
Activity points
1,570
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.

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
 

Hello,

Using other terminal programs which support hex representation (serial watcher, realterm) I could display the data sent by uart.
:)
 

I think you will have to convert the binary value to two ASCII hex characters before you can see them in Hyperterminal. For example, if you wanted to display 12 (hex) you would have to convert it to 31 ('1') and 32 ('2') first then display both as separate characters.

Hint: treat the binary number as two 4-bit halves, if their value is more than 9, add 7 to it, then add 0x30 to the result.

Brian.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top