I have one of the red generic boards with the large LDO on the bottom. I am trying to get MRBurnette’s BlinkNcount example going. When I plug any of the three boards I have into the Win7Pro development machine I am using I get USB device not recognized so I am attempting to use the STLink to upload the SW. When I choose “STM32F103C8 – No Bootloader” from the boards menu, I get the option to use the STLINK and I can successfully compile and upload the “Blinky” example to these boards. However, when I try to compile the BlinkNCount example which uses the Serial functions I get the error –
‘class HardwareSerial’ has no member named ‘isConnected’. If I select the board to be “Generic STM32F103C” from the boards menu, I get a error free compilation, but no option to use the STLINK. Any thoughts?
Thanks,
Gene
Gene
Clearly I need to update some examples as Roger has hacked some of the LeafLab’s Maple-centric functions.
1) For BOARD_LED_PIN you need to do a #define Your LED pin# above setup()
2) toggleLED() was removed from the core (you could write your own function by keeping track of the ON/Off state of the LED… if LED is ON then turn LED OFF. You can also read the state of the LED pin and negate it.)
3) The biggest problem, is you are not using a Maple Mini – therefore, you need to edit Serial. to Serial1. as you will be working on a physical serial port. Roger was working on providing USB serial to generic boards – so, that may work now. Re: viewtopic.php?f=32&t=31#p260
4) Without USB serial, this section of code is not required:
// wait for serial monitor to be connected.
while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
{
toggleLED();
delay(100); // fast blink
}
To get it to work I made 2 changes:
1) pin 33 to PC13
2) I commented out the while loop with the methods that don’t exist for the regular non-usb Serial
// while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS())))
Serial for me is on PA9 and P10 ( USART1 )
Re: Hardware serial issues.
The issue is not something I added, its because LeafLabs added some non Arduino API functions to their codebase that only work with the built in USB Serial.
Specifically isConnected, getDTR. and getRTS
e.g if you try to compile that example for a Uno it gives the same errors
I think we need to rename the mrburnette examples to “Maple mini” examples, as some of them only work on Maple and Maple mini boards (or possibly if we manage to get USB serial working on generic boards)
BTW.
I removed some of the other non-standard API stuff that leaflabs created e.g. SerialUSB has been replaced with Serial , as this is what the Arduino Due and Leonardo do, i.e their “Serial” is via the onboard USB connection.
Re: Pin numbers
The pin number quoted in the Arduino examples e.g. pin 33 for the LED on the Maple are meaningless on generic boards
All generic boards use the native pin name/number which is in the format of Port/PinNumber e.g. PA5 = GPIO Port A, bit 5
Each GPIO port has normally has 16 pins e.g. PA0 to PA15. The small chips like the F103C8 and CB only have ports A B and C, and I think that port C doesn’t have the top 2 or 3 bits, so PC13 may be the last available bit on that chip.
The master reference for this is
http://www.st.com/web/en/resource/techn … 171190.pdf
Leaflabs, Maple mini and Maple boards use Arduino style pin numbers rather than Port / Pin. I presume they thought it was too much of a leap for people to take going to an ARM board and also having to deal with the native port/pin numbers
Anyway, there is a not a lot we can do about this, because people using Maple mini boards have no easy way to know what the pin number’s native name is
I think from memory Maple mini pin 33 is actually PB1, so the Maple mini guys could write that pin name / number in their code and it would work OK, but of course it would be a pain for them to use this number system when their board is not printed with the native pin names ![]()
BTW. The lookup between the native names and the maple pin numbers is in the variant/YOUR VARIANT/board/board.h e.g.
enum {
PB11, PB10, PB2, PB0, PA7, PA6, PA5, PA4, PA3, PA2, PA1, PA0, PC15, PC14,
PC13, PB7, PB6, PB5, PB4, PB3, PA15, PA14, PA13, PA12, PA11, PA10, PA9,
PA8, PB15, PB14, PB13, PB12, PB8, PB1
};
My ultimate goal is to get GRBL running on one of these boards using the USB port as the communications link.
http://forums.leaflabs.com/topic.php?id=95
One of the posts in there talks about configuring one of the pins as an open collector
“For the USB disconnect at D+ I use a 1k5 pullup to 3.3V and a 470Ohm resistor connected to a open collector CPU output pin to pull it down to disconnect.”
You would have to look at the usb code that re initializes the usb stuff and see how to fit something like that in. First step would be to configure the file variants/somepath/board.h with defines for the BOARD_USB_DISC_DEV and BOARD_USB_DISC_BIT you plan to use as the pull down pin.
Then I got adventuresome. I tried a simple test to see if I could get it to have the host enumerate it on demand. I opened a terminal window and did a tail on /var/syslog. Then I loaded the sample code and pressed reset. Nothing changed in the syslog. On a bread board I wired a 100ohm resistor (* what I had lying around) to ground. I took a jumper wire from PA12 and touched the other end of the resistor briefly. To the host it seemed like I had just plugged in a new usb device and it ran its usb handshake stuff. In tail output of syslog I get these messages:
May 3 13:19:17 kimballr-iMac kernel: [260350.605152] usb 1-3.7.2: new full-speed USB device number 58 using ehci-pci
May 3 13:19:18 kimballr-iMac kernel: [260350.701027] usb 1-3.7.2: New USB device found, idVendor=0483, idProduct=5740
May 3 13:19:18 kimballr-iMac kernel: [260350.701032] usb 1-3.7.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
May 3 13:19:18 kimballr-iMac kernel: [260350.701036] usb 1-3.7.2: Product: CDC-ACM Demo
May 3 13:19:18 kimballr-iMac kernel: [260350.701040] usb 1-3.7.2: Manufacturer: Black Sphere Technologies
May 3 13:19:18 kimballr-iMac kernel: [260350.701043] usb 1-3.7.2: SerialNumber: DEMO
May 3 13:19:18 kimballr-iMac kernel: [260350.701609] cdc_acm 1-3.7.2:1.0: This device cannot do calls on its own. It is not a modem.
May 3 13:19:18 kimballr-iMac kernel: [260350.701638] cdc_acm 1-3.7.2:1.0: ttyACM1: USB ACM device
Btw, I didn’t remove the maple specific serial functions, e.g. isConnnected.
Its just that only the built in serial USB can support those functions.
So if I just rename the mrbrunette folder to maple mini examples, and perhaps add a readme that explains some examples only work on maple mini
Btw, I didn’t remove the maple specific serial functions, e.g. isConnnected.
Its just that only the built in serial USB can support those functions.
So if I just rename the mrbrunette folder to maple mini examples, and perhaps add a readme that explains some examples only work on maple mini
USBSerial nativeSerial;
void setup() {
nativeSerial.begin();
}
void loop() {
static int cnt;
nativeSerial.println(cnt++);
delay(1000);
}
Can you tell me what board you have selected in the menu and what you are using to upload the code?
Thanks
Thanks!
I had a backup board shipped to me and tried your code and it works great. Many thanks. Only thing I had to do was capitalize the S in the nativeSerial declaration.
Thanks again, I can now make some progress.
Blink with -DSERIAL_USB
Sketch uses 15,608 bytes (14%) of program storage space. Maximum is 108,000 bytes.
Global variables use 4,504 bytes of dynamic memory.
Blink without -DSERIAL_USB
Sketch uses 13,868 bytes (12%) of program storage space. Maximum is 108,000 bytes.
Global variables use 3,872 bytes of dynamic memory.
So the option uses a minimum of 1740 bytes of flash and 1532 bytes of ram. Not insignificant numbers if space is tight in your project, and you don’t need USB serial.
FYI, I ordered 5 maple mini clone boards thru Aliexpress on 5/5 and they arrived on 5/22. Seventeen days using the free shipping option, not too bad!
Gene
Great. That has been my experience with units of 5x to 10x. The 1x seems to be a bit slower in delivery.
Ray

