UART interrupt

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

UART interrupt

1,436 次查看
Alex_2221
Contributor IV

Hello everyone, I working on a project with LPC1768. I'm reading 2 temperatures from 2 sensors and send them two a phone via bluetooth continuously. Now I want to add interrupt in order to send 2 digit numbers to the board via bluetooth and echo back the numbers, while continuously sending the 2 temperatures to them phone. When I wanted to activate interrupt and I added the two lines below:

UART_IntConfig(LPC_UART3, UART_INTCFG_RBR,ENABLE);
NVIC_EnableIRQ(UART3_IRQn);

My board only sent the temperature 3-4 and stopped communication with my phone. What I'm doing wrong?

I added my main code below also I attached the main.c and Hardware.c ( configurations where I activate the interrupt).

 Thanks in advance, 

  Alex

main code :

#include <stdio.h>

#include "lpc17xx_gpio.h"
#include "lpc17xx_pinsel.h"
#include "lpc17XX_uart.h"
#include "lpc17XX_adc.h"

#include "Hardware.h"
#include "Delay_RIT.h"

//void UART_IntReceive(void)
//{
// uint8_t data= UART_ReceiveByte(LPC_UART3);
// UART_SendByte(LPC_UART3,data);
//
//
//}

int main()
{
uint8_t buffstr [20];
//uint8_t buffstr2 [20];

// uint8_t setTemp [1];

// GPIO_SetDir(2,(1<<0),1);

HW_Init();

while(1)
{
uint16_t temp1 = HW_ADC_Read1();
uint16_t temp2 = HW_ADC_Read2();


uint8_t len= sprintf( (char*)buffstr," %u\n %u\n ",temp1,temp2);
UART_Send(LPC_UART3,buffstr,len,NONE_BLOCKING);

Delay_RIT_ms(1000);


}

}

 

 

0 项奖励
回复
5 回复数

1,400 次查看
Alex_2221
Contributor IV

@xiangjun_rong  What's your opinion?

0 项奖励
回复

1,416 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Alex,

Please check whether there is UART receive interrupt after your phone send 5-6 numbers.

 

BR

Alice

0 项奖励
回复

1,406 次查看
Alex_2221
Contributor IV

Thanks I'll check that, but actually my phone should receive data from the board continuously, not sending them 5-6 times

0 项奖励
回复

1,391 次查看
frank_m
Senior Contributor III

I don't think this is the right way to tackle your problem.

Split your problem up in small sub-units you can easily observe.

I.e. check the serial communication to the attached BT module (if I got that right), and see if it matches your expectations. You can involve the smartphone later if you know that works.

You might need a scope for that - and the debugger of course.

0 项奖励
回复

1,384 次查看
Alex_2221
Contributor IV

Yeah a scope and a debuger would help, but have been working on this project for some time and can't figure out what the problem is I can echo back data sometimes, but can't read the temperatures continously. Thank you

0 项奖励
回复