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.
5 years, 2 months ago. This question has been closed. Reason: Duplicate question
Serial scanf does not work
I use STMF303RE.
I connected PC_12 and PD_12 directly. And I ran the following program, but it stopped at line 11, scanf
include the mbed library with this snippet
#include "mbed.h" Serial self(PC_12,PD_2); Serial pc(USBTX,USBRX); DigitalOut led1(LED1); int data; void toggle_led() { led1 = !led1; pc.printf("before\n\r"); self.scanf("%d",data); pc.printf("get %d\n\r",data); } int main() { led1 = 1; //double test = 0x0123456789abcdef; //double test = 0xfedcba9876543210; int test2 = 0x1234; self.attach(toggle_led,Serial::RxIrq); while(1){ wait(2); //self.printf("%lf",test); self.printf("%d",test2); //self.putc('a'); } }
What is wrong? Please help me.