• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

hyperterm to uart(rx)

Status
Not open for further replies.

butters

Member
Code:
#pragma interrupt rx_handler
void rx_handler (void)
{
  unsigned char c;


  /* Get the character received from the USART */
  c = ReadUSART();
  if (IPR1bits.RCIP)
    {
     
      /* Display value received on LEDs */
      PORTB = c;

      //putsUSART (data[c]);// writes string of character from data[c]
    }
  else
    {

      putsUSART (data[11]);

      /* Display value received on LEDs */
      PORTB = c;
    }


    /* Clear the interrupt flag */
    PIR1bits.RCIF = 0;
}

hi all is there any specific setting that i need to do so that my values from hyperterm would be display in int c as it a ReadUSART() which captures from it...?
 

Pommie

Well-Known Member
Most Helpful Member
I don't understand your question. I also don't understand why you are testing the interrupt priority bit in the interrupt.

If you post some complete code with an explanation of what you think it should do and what it actually does then you are far more likely to get an answer.

Mike.
 

butters

Member
Code:
void main (void)
{


TRISC = 0b00100000; //set RC7 and RC5 as output and RC6 as input
ADCON1 = 0x0F;


  OpenUSART (USART_TX_INT_OFF &
             USART_RX_INT_ON &
             USART_ASYNCH_MODE &
             USART_EIGHT_BIT &
             USART_CONT_RX &
             USART_BRGH_HIGH, 25);

//transmit
//set RC5 to 1 to enable tx transmission
PORTCbits.RC5 = 1;

	//value sent
	putcUSART(0x66);

PORTCbits.RC5 = 0;




/* Enable interrupt priority */
 RCONbits.IPEN = 1;

  /* Make receive interrupt high priority */
  IPR1bits.RCIP = 1;

  /* Enable all high priority interrupts */
  INTCONbits.GIEH = 1;

  /* Loop forever */
  while (1);
}
here is a main part of the code.. the usart is suppose to transmit a hex value of 66 to the hyperterminal. the hex value will display as "f" in terms of ascii format..while it is transmitting, an interrupt of receiving from hyperterminal occurs.. here is the interrupt routine...


Code:
//location of the ISR
#pragma code rx_interrupt = 0x8
void rx_int (void)
{
  _asm goto rx_handler _endasm
}
#pragma code  //return to default code section

#pragma interrupt rx_handler
void rx_handler (void)
{
  unsigned char c;


  /* Get the character received from the USART */
  c = ReadUSART();

  if (IPR1bits.RCIP)
    {
     
      /* Display value received on LEDs */
      PORTB = c;

      //putsUSART (data[c]);// writes string of character from data[c]
    }
  else
    {

      putsUSART (data[11]);

      /* Display value received on LEDs */
      PORTB = c;
    }


    /* Clear the interrupt flag */
    PIR1bits.RCIF = 0;
}
this is the interrupt service routine which im working on.
im suppose to make char c capture values from the hyperterm through ReadUSART()..

upon successful receiving, i need to do a watch window so that the values from the hyperterminal reflect on it...

but theres isnt any values coming out from the char c in watch window...



i hope this clears everything...
thanks..
 

Pommie

Well-Known Member
Most Helpful Member
What is the line,

if (IPR1bits.RCIP)

supposed to do?

And you have still posted part code. Maybe you set port B to output somewhere maybe not. Without code that compiles, everyone has to guess what your code does and so the chances of anyone working out the error are practically nil.

Mike.
 

butters

Member
What is the line,

if (IPR1bits.RCIP)

supposed to do?

And you have still posted part code. Maybe you set port B to output somewhere maybe not. Without code that compiles, everyone has to guess what your code does and so the chances of anyone working out the error are practically nil.

Mike.

im stuck until the if (IPR1bits.RCIP) part.. i dont know how to continue from there... but the problem now is that theres isnt any values coming from the char c...
 
Status
Not open for further replies.

EE World Online Articles

Loading
Top