about UART INTERRUPT

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

about UART INTERRUPT

Jump to solution
1,536 Views
about
Contributor II
Hi,everyone Now,I'm learning about MQX uart component on the MCF 52259 demon board. I want to use the uart interrupt mode to receive data from my computer.I use the command "read()" to get the data from uart buffer. In fact, I want to receive the unmixed data,so I define a variable uart_buffer_rx in the function _mcf52xx_uart_serial_int_isr() to record the data number from my computer. I found when I input the string "yangyin",the softare can give the data "yangyin".However,after doing this,I input the string "zhen",it still give me the data "zhenyin".I can't find anyways to solve the question.Please help me ,thanks. Here is my code.
0 Kudos
1 Solution
540 Views
about
Contributor II
Hi, According to your method, I have resolved the question. Thanks.

View solution in original post

0 Kudos
4 Replies
540 Views
madifazio
Contributor III

Hi,

You need to null terminate your buffer. 

read(fh_ptr,bptr,uart_buffer_rx); maybe returns the number of read chars. You could use this value to put a "\0" in your bufffer.

 

EJ:

int read_chars = read(....);

*(bptrr + read_chars) = 0;

 

Regards

0 Kudos
541 Views
about
Contributor II
Hi, According to your method, I have resolved the question. Thanks.
0 Kudos
540 Views
admin
Specialist II

Hello I am trying to configure the TWR52259 UART 2 as interrupt UART to test the PPP (Point-to-Point) Example Application. The problem is that I need to use the UART1 UCTS1 and URTS1 pins (Tertiary function of PUBPAR ports 2 and 3: UTXD2 and URXD2).


First. I tried to test the printf function (Default IO channel) for the UART 2 to see if everything was right for that UART but I Cannot see anything on my console.


I have made the following changes to the BSP to configure the Default IO Channel to the TTYC:

1. Change the Default IO chanel definition in twrmcf52259.h file:

 BSP_DEFAULT_IO_CHANNEL   "ttyc:"


2. Enable TTYC in user_config.h file:

 #define BSPCFG_ENABLE_TTYA       1
 #define BSPCFG_ENABLE_TTYB       0
 #define BSPCFG_ENABLE_TTYC       1
 #define BSPCFG_ENABLE_ITTYA      0
 #define BSPCFG_ENABLE_ITTYB      1
 #define BSPCFG_ENABLE_ITTYC      0


3. Change the PUBPAR ports 2 and 3 to the tertiary function (case 2) at the _bsp_serial_io_init function as next:


_mqx_int _bsp_serial_io_init
(
   uint_8 dev_num
)
{
 VMCF5225_STRUCT_PTR reg_ptr = _PSP_GET_IPSBAR();
 
 switch (dev_num) {
     case 0:
        reg_ptr->GPIO.PUAPAR |= 0
           | MCF5225_GPIO_PUAPAR_TXD0
           | MCF5225_GPIO_PUAPAR_RXD0;
        break;
     case 1:
        reg_ptr->GPIO.PUBPAR |= 0
           | MCF5225_GPIO_PUBPAR_TXD1
           | MCF5225_GPIO_PUBPAR_RXD1;
        break;
   case 2:

 /*tertiary function of PUBPAR ports 2 and 3*/
    reg_ptr->GPIO.PUBPAR |= 0
           | MCF5225_GPIO_PUBPAR_TXD2
           | MCF5225_GPIO_PUBPAR_RXD2;
 

 /*FOR NORMAL UART 2, commented*/
        /*reg_ptr->GPIO.PUCPAR |= 0
           | MCF5225_GPIO_PUCPAR_TXD2
           | MCF5225_GPIO_PUCPAR_RXD2;*/
 /*FOR NORMAL UART 2, commented*/
      break;
  default:
     return -1;
} /* Endswitch */

 return 0;
}


I don't know what I am doing wrong or what else I need to do to make printf function works in TTYC in the UART1 UCTS1 and URTS1 pins.


Once I ensure the TTYC works fine I will proceed to the next step: test the PPP (Point-to-Point) Example Application in UART 2 .


My objective is to get GPRS connectivity through PPP and a MODEM


Can anyone help me or giveme some advice to achieve my objective.

I will appreciate that.


Thank you and my best regards.


Alejandro.

0 Kudos
540 Views
admin
Specialist II

Hello again.

 

I did it! :smileyvery-happy:

 

The problem was the TTL signal to RS232 converter device I was using. Apparently something was wrong with the circuit.

 

The three steps to configure the BSP mentioned above are necessary to use the UART2 (TTYC) as the DEFAULT IO CHANNEL (printf function) using the UART1 UCTS1 and URTS1 pins (Tertiary function of PUBPAR ports 2 and 3: UTXD2 and URXD2).

 

Now what I am going to do is to proceed to test the PPP (Point-to-Point) Example Application in the modified UART2 but configuring it now as Interrupt UART because the readmy file of the PPP App gives some BSP configuration to use the PPP protocol in any UART.

 

Once I make the PPP App work fine then I will try to implement the GPRS connectivity.

 

First I will try to implement a PPP client on TWR52259 to get a local IP Address, Public IP Address, mask and Gateway from any host that works as a PPP bridge to internet (for example a computer with Windows XP/7, It is easy to configure the COM port as a PPP Bridge).

 

If all works then.... Straight to the major leagues!!! Make the GPRS connectivity and for example access the TWR52259 embedded HTTP server through it's GPRS connection.

 

If anyone has some advice, solution or information to achieve that objective I will appreciate that.

 

Thanks and my best regards.

 

Alejandro.

0 Kudos