Get ADC and send through BLE qn9080-DK

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

Get ADC and send through BLE qn9080-DK

5,970 Views
ashkanrezaee
Contributor III

Hi,
I want to use and change wireless uart program to get some data from ADC and send it through BLE to phone. Is there anyone to help me? I do not know what I should change in the program.
Thanks

qn9080-dk‌ blutooth‌ ADC uart

Labels (3)
37 Replies

1,331 Views
michalisantonio
Contributor I

How to receive data, through USART, when run private_profile_server project??

0 Kudos

1,331 Views
xing_chang
NXP Employee
NXP Employee

Yes, you can make to a macro definition gSerialManagerMaxInterfaces_c, then through a serial port input and output, reference w_uart project.

0 Kudos

1,331 Views
michalisantonio
Contributor I

Hi,

I use this to send data over USART and works OK: USART_WriteBlocking(DEMO_USART, g_tipString, sizeof(g_tipString) / sizeof(g_tipString[0]));

How can I receive data from another device like Arduino over USART? Which part of w_uart project I need copy into private_profile_server project? 

0 Kudos

1,331 Views
xing_chang
NXP Employee
NXP Employee

Hi Michalis,

You can register the callback function with Serial_SetRxCallBack(gAppSerMgrIf, Uart_RxCallBack, NULL) and then process the received data in the callback function 'Uart_RxCallBack'.

0 Kudos

1,331 Views
xing_chang
NXP Employee
NXP Employee

Hi Michalis,

I think the private_profile_server project is better for you, all you need to do is change the data that Qpp_SendData is sending.

result = Qpp_SendData(mPeerInformation[i].deviceId, service_qpps, mQppsTestDataLength, tx_data);

Simply replace tx_data with ADC data.

0 Kudos

1,331 Views
anniehung05911
Contributor II

Hi,

I have a similar problem of Get  ADC value and send through BLE by QN9080-DK

I want to ask for

I set the sample rate = 250 Hz in ADC function.

Then I want to set up a timer in the BLE Code that can call the ADC Function by interrupt every 1/250 sec to get the ADC value.

How to create this timer?

I have found like SysTick, CTimer, ... But I didn't know how to use it

If someone knows, please tell me,

Thanks.

0 Kudos

1,331 Views
xing_chang
NXP Employee
NXP Employee

Hi anniehung05911@gmail.com‌,

The fastest way to do this is to refer to the battery measurement timer in the BLE routine and define a timer yourself,

like this:

static tmrTimerID_t mBatteryMeasurementTimerId;

mBatteryMeasurementTimerId = TMR_AllocateTimer();

TMR_StartLowPowerTimer(mBatteryMeasurementTimerId, gTmrLowPowerIntervalMillisTimer_c,
       TmrSeconds(mBatteryLevelReportInterval_c), BatteryMeasurementTimerCallback, NULL);

TMR_StopTimer(mBatteryMeasurementTimerId);

Details are available in the documentation "Connectivity Framework Reference Manual" section 3.4 "Timer's Manager",

at dir "SDK\docs\wireless\Common".

0 Kudos

1,331 Views
anniehung05911
Contributor II

Hi,

I use DMA Controller to get the ADC value and then send through BLE

I want to merge 2 sample code - adc_dma & private_profile_server

I add dma.c and dma.h file to private_profile_server project, but it didn't work.

Where is suggest to add the function in the code?

Now I put adc_dma project main function as a function in the private_profile_server.c

But the DMA controller didn't work, and the setting in Peripheral - DMA0 didn't change.

0 Kudos

1,331 Views
xing_chang
NXP Employee
NXP Employee

Hi Wei-Min,

Have you set the corresponding pin to ADC function?
Like this,

Header 1
const uint32_t portA_pin8_config = (
IOCON_FUNC1 | /* Selects pin function 1 */
IOCON_MODE_HIGHZ | /* Selects High-Z function */
IOCON_DRIVE_LOW /* Enable low drive strength */
);
IOCON_PinMuxSet(IOCON, PORTA_IDX, PIN8_IDX, portA_pin8_config); /* PORTA PIN8 (coords: 46) is configured as ADC4 */





0 Kudos

1,331 Views
xing_chang
NXP Employee
NXP Employee

Hi Michalis,

You can do type conversion like this:

float adc_mv = 1.1;
result = Qpp_SendData(mPeerInformation[i].deviceId, service_qpps, sizeof(float), (uint8_t*)&adc_mv);
0 Kudos

1,331 Views
michalisantonio
Contributor I

Thanks! Data send in ADC driver example are float. But private_profile_server project send uint8_t data. I use  ADC driver example functions inside private_profile_server project. I need convert float to uint8_t data before send ADC data to QPP phone app ? If so is there an instruction I can use to convert float to uint8_t ? 

0 Kudos

1,331 Views
michalisantonio
Contributor I

How to create multicore project with wirless_uart project as master and ADC driver example as slave? So can read ADC data, using ADC driver SDK example, and send over BLE using  wirless_uart SDK project?

0 Kudos

1,331 Views
xing_chang
NXP Employee
NXP Employee

Hi Michalis,

Are you using QN9080? If yes, but the QN9080 is a single core chip.

0 Kudos

1,331 Views
xing_chang
NXP Employee
NXP Employee

Hi Ashkan,

Maybe you can make the following changes in the wirless_uart project:

static void BleApp_ReceivedUartStream(deviceId_t peerDeviceId, uint8_t *pStream, uint16_t streamLength)

{

...

//FLib_MemCpy(pBuffer + messageHeaderSize, pStream, streamLength - messageHeaderSize);
//Serial_AsyncWrite(gAppSerMgrIf, pBuffer, streamLength, Uart_TxCallBack, pBuffer);

if(FLib_MemCmp(pStream, "command A", sizeof("command A")))

{

//do something

}

1,331 Views
ashkanrezaee
Contributor III

I think this function use for receiving data. But I want to send the result of the ADC to phone. So I think I should change

"static void BleApp_FlushUartStream(void *pParam)..." function.

Am I correct? if yes, how? if no, please explain more.

Thanks

0 Kudos

1,331 Views
xing_chang
NXP Employee
NXP Employee

Yes,

Simply send the data you want to send through the BleApp_SendUartStream function.

However, I think the private_profile_server project might be more suitable for you, which includes a process for sending data at regular intervals.

0 Kudos

1,331 Views
gerardo_rodriguez
NXP Employee
NXP Employee

Hello Ashkan Rezaee,

I recommend running the ADC driver example applications included with the QN908x SDK, so you get familiar with the ADC SDK driver and then add the required functionality to the BLE Wireless UART application. For example, in MCUXpresso IDE, you can import the ADC basic driver example (next image) and go through the doc\readme.txt file for a description of the application.

pastedImage_1.png

Let me know if you have any question.

Regards,

Gerardo