Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 8 months ago.
Error writing Serial Data, public command "write" not accessible within my defined function
#include "mbed.h" #include <stdint.h> enum State { off, on }; void Sample(); Serial COM(PTD3, PTD2); // serial object to communicate with the other k22f Ticker Sample_func; // timer object DigitalOut Flash(PTD4); // Pin PTD4 will output 3.3V State state = on; AnalogIn ADC_PIN(PTB0); // analogue pin PwmOut PWM_Brightness(PTC3); // LED pin float ADC_value = 0; float Temp = 0; int main() { Flash = state; // put power on PWM_Brightness.period(0.0005); COM.baud(57600); COM.format(8, SerialBase::None, 1); // setting COM paramters Sample_func.attach(Sample, 0.1); while (true) ; } void Sample() { ADC_value = ADC_PIN.read(); uint8_t Send = (int)(255 * ADC_value); if (((int)(100 * ADC_value)) != ((int)(100 * Temp))) { COM.write(&Send,1); // send data } PWM_Brightness.write(ADC_value); Temp = ADC_value; }
1 Answer
8 years, 8 months ago.
Please use the <<code>> and <</code>>
tags around your poster code to keep it readable.
The write methods are part of the new asynchronous operations which are currently only supported by the Silicon Labs platforms. Unfortunately that fact is very badly documented. You should replace it with your own call to number of putc () operations.