I want to know if I running project uartecho_CC2650F128 ,
Can I see any messages from my PC , I want to see data use this software:
Thank you.
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
In fact , It's arduino code , the sensor is PH sensor , and they only PO Arduino code .
#include <SoftwareSerial.h> //we have to include the SoftwareSerial library, or else we can't use it
#define rx 2 //define what pin rx is going to be
#define tx 3 //define what pin tx is going to be
SoftwareSerial myserial(rx, tx); //define how the soft serial port is going to work
String inputstring = ""; //a string to hold incoming data from the PC
String sensorstring = ""; //a string to hold the data from the Atlas Scientific product
boolean input_string_complete = false; //have we received all the data from the PC
boolean sensor_string_complete = false; //have we received all the data from the Atlas Scientific product
float pH; //used to hold a floating point number that is the pH
void setup() { //set up the hardware
Serial.begin(9600); //set baud rate for the hardware serial port_0 to 9600
myserial.begin(9600); //set baud rate for the software serial port to 9600
inputstring.reserve(10); //set aside some bytes for receiving data from the PC
sensorstring.reserve(30); //set aside some bytes for receiving data from Atlas Scientific product
}
void serialEvent() { //if the hardware serial port_0 receives a char
inputstring = Serial.readStringUntil(13); //read the string until we see a <CR>
input_string_complete = true; //set the flag used to tell if we have received a completed string from the PC
}
void loop() {
if (input_string_complete) { //if a string from the PC has been received in its entirety
myserial.print(inputstring); //send that string to the Atlas Scientific product
myserial.print('\r'); //add a <CR> to the end of the string
inputstring = ""; //clear the string
input_string_complete = false; //reset the flag used to tell if we have received a completed string from the PC
}
if (myserial.available() > 0) { //if we see that the Atlas Scientific product has sent a character
char inchar = (char)myserial.read(); //get the char we just received
sensorstring += inchar; //add the char to the var called sensorstring
if (inchar == '\r') { //if the incoming character is a <CR>
sensor_string_complete = true; //set the flag
}
}
if (sensor_string_complete == true) { //if a string from the Atlas Scientific product has been received in its entirety
Serial.println(sensorstring); //send that string to the PC's serial monitor
if (isdigit(sensorstring[0])) { //if the first character in the string is a digit
pH = sensorstring.toFloat(); //convert the string to a floating point number so it can be evaluated by the Arduino
if (pH >= 7.0) { //if the pH is greater than or equal to 7.0
Serial.println("high"); //print "high" this is demonstrating that the Arduino is evaluating the pH as a number and not as a string
}
if (pH <= 6.999) { //if the pH is less than or equal to 6.999
Serial.println("low"); //print "low" this is demonstrating that the Arduino is evaluating the pH as a number and not as a string
}
}
sensorstring = ""; //clear the string
sensor_string_complete = false; //reset the flag used to tell if we have received a completed string from the Atlas Scientific product
}
}
sensor datasheet : pH_EZO_datasheet.pdf
Thank you.
I refer project uartecho_CC2650F128 , and copy two lines :
and paste that code on SimpleBLEPeripheral.c
static void SimpleBLEPeripheral_init(void)
{
char input;
const char echoPrompt[] = "\fEchoing characters:\r\n";
UART_Params_init(&uartParams);
uartParams.writeDataMode = UART_DATA_TEXT;
uartParams.readDataMode = UART_DATA_TEXT;
uartParams.readReturnMode = UART_RETURN_FULL;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.baudRate = 9600;
/* UART Open */
uart = UART_open(CC2650_UART0, &uartParams);
UART_write(uart, echoPrompt, sizeof(echoPrompt));
while (1) {
UART_read(uart, &input, 1);
UART_write(uart, &input, 1);
}
ledPinHandle = PIN_open(&ledPins, ledPinsTable);
PIN_setOutputValue(ledPinHandle, Board_LED1, 1); //It's not work?
Do I miss something?
Hello,Yikai:
I know how to read data via UART , and I am sucessed.
but I want to know your idea , seems very good.
so I modify echo fxn behide void SimpleBLEPeripheral_createTask(void) :
void uart_createTask(void)
{
Task_Params_init(&taskParams);
taskParams.stackSize = TASKSTACKSIZE;
taskParams.stack = &task0Stack;
Task_construct(&task0Struct, (Task_FuncPtr)echoFxn, &taskParams, NULL);
}
and it's not working
You can use the following codes to replace the code in main.c of SimpleBLEPeripheral. I have test it and see it works fine.
#include <xdc/runtime/Error.h>
#include <ti/sysbios/family/arm/cc26xx/Power.h>
#include <ti/sysbios/BIOS.h>
#include "ICall.h"
#include "bcomdef.h"
#include "peripheral.h"
#include "simpleBLEPeripheral.h"
/* Header files required to enable instruction fetch cache */
#include <inc/hw_memmap.h>
#include <driverlib/vims.h>
#include <ti/drivers/UART.h>
#include <ti/sysbios/knl/Task.h>
#ifndef USE_DEFAULT_USER_CFG
#include "bleUserConfig.h"
// BLE user defined configuration
bleUserCfg_t user0Cfg = BLE_USER_CFG;
#endif // USE_DEFAULT_USER_CFG
/**
* Exception handler
*/
void exceptionHandler()
{
volatile uint8_t i = 1;
while(i){}
}
#ifdef FEATURE_OAD
#if defined(__IAR_SYSTEMS_ICC__)
extern uint32_t __vector_table;
#elif defined (__TI_COMPILER_VERSION__)
extern uint32_t ti_sysbios_family_arm_m3_Hwi_resetVectors;
#endif //Compiler
#endif //FEATURE_OAD
/*
* ======== echoFxn ========
* Task for this function is created statically. See the project's .cfg file.
*/
Void echoFxn(UArg arg0, UArg arg1)
{
char input;
UART_Handle uart;
UART_Params uartParams;
const char echoPrompt[] = "\fEchoing characters:\r\n";
/* Create a UART with data processing off. */
UART_Params_init(&uartParams);
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.readReturnMode = UART_RETURN_FULL;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.baudRate = 9600;
uart = UART_open(CC2650_UART0, &uartParams);
if (uart == NULL) {
//System_abort("Error opening the UART");
return;
}
UART_write(uart, echoPrompt, sizeof(echoPrompt));
/* Loop forever echoing */
while (1) {
UART_read(uart, &input, 1);
UART_write(uart, &input, 1);
}
}
#define TASKSTACKSIZE 768
Task_Struct task0Struct;
Char task0Stack[TASKSTACKSIZE];
/*
* ======== main ========
*/
int main()
{
PIN_init(BoardGpioInitTable);
Task_Params taskParams;
/* Call board init functions */
UART_init();
/* Construct BIOS objects */
Task_Params_init(&taskParams);
taskParams.stackSize = TASKSTACKSIZE;
taskParams.stack = &task0Stack;
Task_construct(&task0Struct, (Task_FuncPtr)echoFxn, &taskParams, NULL);
#ifndef POWER_SAVING
/* Set constraints for Standby, powerdown and idle mode */
Power_setConstraint(Power_SB_DISALLOW);
Power_setConstraint(Power_IDLE_PD_DISALLOW);
#endif // POWER_SAVING
/* Initialize ICall module */
ICall_init();
/* Start tasks of external images - Priority 5 */
ICall_createRemoteTasks();
/* Kick off profile - Priority 3 */
GAPRole_createTask();
SimpleBLEPeripheral_createTask();
#ifdef FEATURE_OAD
{
uint8_t counter;
uint32_t *vectorTable = (uint32_t*) 0x20000000;
#if defined(__IAR_SYSTEMS_ICC__)
uint32_t *flashVectors = &__vector_table;
#elif defined(__TI_COMPILER_VERSION__)
uint32_t *flashVectors = &ti_sysbios_family_arm_m3_Hwi_resetVectors;
#endif //Compiler.
// Write image specific interrupt vectors into RAM vector table.
for(counter = 0; counter < 15; ++counter)
{
*vectorTable++ = *flashVectors++;
}
}
#endif //FEATURE_OAD
/* enable interrupts and start SYS/BIOS */
BIOS_start();
return 0;
}
/**
* Error handled to be hooked into TI-RTOS
*/
Void smallErrorHook(Error_Block *eb)
{
for (;;);
}
/**
* HAL assert handler required by OSAL memory module.
*/
void halAssertHandler(void)
{
for (;;);
}