I wrote a small program on PlatformIO for an ESP32 with ESP-IDF framework.
Currently this is connected to my PC with USB cable.
I receive lots of data from a CAN-BUS and I print this data with printf()
It seems the output with the standard baud rate 115200 is too slow. This is why I want to set this to a higher value.
I changed this in the platformio.ini without success.
monitor_speed = 115200
I searched and did not find where I can change this baud rate.
If possible my idea is to add some code, maybe just a line or two, to set the value i.e. to 230400
I mention the ESP32, PlatformIO and ESP-IDF because I am not sure where this setting is supposed to be.
It is a setting of esp-idf framework. You can set the console baud rate in sdkconfig.defaults (at project root directory):
CONFIG_CONSOLE_UART_BAUDRATE=230400
You can also configure it via menuconfig (idf.py menuconfig or pio run -t menuconfig):
Component config
Common ESP-related
UART console baud rate
Related
I have a Arduino Micro connected via usb to my pc, showing up as /dev/arduino.
Now when I want to program it (it currently has the default bootloader from Arduino) I have to boot it into the bootloader. AFAIK this can be done by either resetting the chip or talking to it using the baudrate 1200.
For this I have a script like
#!/usr/bin/env python
import serial
s = serial.Serial(
port="/dev/arduino",
baudrate=1200,
bytesize=serial.EIGHTBITS,
stopbits=serial.STOPBITS_ONE,
parity=serial.PARITY_NONE)
s.isOpen()
s.close()
The problem is, that the script as well as the reset pin do not work reliably. Also cutting the power source from the device usually does not kick it into bootloader.
How can I reliably put my Arduino Micro into bootloader? Preferably over USB.
The Python script you posted really should work. You did not say what your evidence is for why it is not working so I can only guess what might be the problem. My guess would be that you need to add a delay after closing the port because it will take some time for the computer to detect the bootloader, enumerate it, and create the serial ports for it. A delay of one or two seconds ought to be enough.
Another guess would be that the code you are running on your Arduino Micro interferes with USB interface. For example, you might have an interrupt service routine that runs for a long time or you might be disabling interrupts in your mainline code for a long time. If you don't let the Arduino's USB interrupts run promptly, they cannot do their job reliably.
the magic isn't within the arduino IDE but instead on the avrdude sequence.
you can install another avrdude on your system, or use the same one which comes with arduino, but you can make a reset simulating a small signature read with avrdude (avrdude -c arduino -p m328p -P com1)...
but to be completely honest, the real trick is on the arduino's reset circuit. the reset pin is connected to serial DTR via a capacitor (and sometimes rts), so each time avrdude switch the serial configuration to program via rs232 it produce a small pulse on DTR (about 50ms it seems) which causes a reset on the microcontroller. i think you can use s.setDTR(True); time.sleep(0.05); s.setDTR(False) to generate a small pulse to reset your arduino within python...
good luck
So I have succesfully attached a Esp8266 to an Arduino Due. I can communicate with it via Serial Monitor if I choose the Baudrate to be 74880. Then all the commands come to it correctly and can be read back correctly. However, when I send the command AT+RST which restarts the Esp8266 I can no longer communicate with it and need to reopen the serial connection with a Baudrate of 115200. I have to repeat this every time I load the code new to the Arduino or when I power off the Esp8266.
Any ideas where this behaviour comes from?
Here you are an explanation about where are the origins of such a behavior:
Baudrate of 74880 Bd is ESP's 'native' baud rate for sending debug messages generated automatically by the system itself during the boot in case there is 26 MHz instead of 40 MHz crystal used on board - and as we can see, mostly that is the case.
With 40 MHz crystal the baudrate would be as expected (115200) but with 26 MHz crystal instead, baudrate is 115200 * 26/40 = 74880.
Later after bootloader ends baudrate is controlled in other way so that's why you have two different baudrates - the first is the default one (74880) and the second is the one that is active later (the one you can set).
I usually set baudrate to 74880 so I can see both the messages generated automatically and the messages I send from the code.
In order to set UART baudrate persistent after a reset you should use AT+UART_DEF.
From the AT instruction :
AT+UART_DEF – default UART configuration This command sets the UART configuration and save it to flash. It is stored as the default
parameter and will also be used as the default baudrate henceforth.
Expected first printf line of software to serial output to Windows7 PC is:
main() ************************** SW START Project 2016-10-30 x1
Actual serial output (at TeraTerm or PuTTY);
▒▒▒▒()j**j*j**j*j**j*j**j*j**j*j ▒▒Ӕ▒Ҕ ▒▒▒▒▒▒▒ r01v-q0-30▒q
Serial worked great from mbed or VisualGDB to NUCLEO evaluation board.
ie.:
Serial pc(USBTX, USBRX);
Now, I'm running VisualGDB to the actual target board with a STM32F091RC.
ie.:
Serial pc(SERIAL_TX, SERIAL_RX);
At 9600, some chars are correct, most are garbage.
I've tried alternate target and cables, same problem. PC's Terminal program (TeraTerm or PuTTY) set at 8,n,1.
Looked in mbed library; default config is 8 data, no parity, 1 stop.
USB/serial converter cable is: FTDIChip TTL-232R-RPi (normally for Raspberry Pi).
It could be clock mismatch between eval board and target board. Assuming, you have correct grounding.
Another issue could be number of data bits in configs is off.
I guess it is not relevant anymore, but you have to pay attention to this points.
The Signal level is 3.3v and not 5v, not all USB Uart adapters work correctly with is
The polarity is the inverted to the standard, i.e. start bit is 1.5bit low like here
Ensure you have correct parity and bits. Most people (and Arduino) use 8N1 by default, but STM32 sample code uses 7O1 by default. See here: https://community.st.com/thread/40340-stm32cubefwf2v140projectsstm32f207zg-nucleoexamplesuartuartprintf-printing-garbage-data-over-the-terminal
I am trying to connect ATmega128 uart to PC using USB-to-RS232 converter so that PC can receive and transmit data from microcontroller using hyper terminal. I set the correct stop bits and baud rate in hyper terminal. It doesn't seem to work.
Can any one tell me if this is possible by USB-to-RS232 converter and if not what other options are there for serial communication between PC and microcontroller ?
You should be able to do this without any issues. I'd suggest putting your USB-to-RS232 cable in loopback mode first (if possible) to ensure you can communicate, then connect it back up to your MCU.
If you aren't seeing what you expect the first thing to look at are the settings, specifically the baud rate. Since your USB-to-RS232 cable is from a third party vendor I'd assume that your settings on the host side are OK. So you should look in to your MCU code to ensure that all your clocks are running at the proper speed and you have indeed performed the correct calculations to achieve your desired baud rate. Debugging here to ensure you are transmitting data out of the device is important.
Additionally, there are tools that can help you debug. Portmon is a tool from Microsoft that lets you look at the serial data path on the host side. I'd also recommend a USB analyzer, such as an Ellisys, that will allow you to view data going across the line from your MCU to the host.
Whenever I need to upload the bootloader to my Arduino Mega (ATMEGA2560) I use an AVRISP MKII with the fuses/lock bits described in boards.txt file. Doing this I am able to burn arduino sketches by serial connection with my FTDI.
My question is: is it possible to burn arduino sketches (.hex files) with the AVRISP but keeping the bootloader? Whenever I try to do that (I use the same avrdude command I use to program the bootloader but changing the bootloader .hex file to the sketch .hex file) I am no longer able to program the processor with FTDI (and then I need to program the bootloader again).
I think (of course I can be wrong) this problem occurs due to the fuse and lock bits settings that cannot be the same as those used to program the bootloader.
This is the fuse settings I use (from boards.txt file under Arduino folder)
mega2560.name=Arduino Mega 2560 or Mega ADK
mega2560.upload.protocol=wiring
mega2560.upload.maximum_size=258048
mega2560.upload.speed=115200
mega2560.bootloader.low_fuses=0xFF
mega2560.bootloader.high_fuses=0xD8
mega2560.bootloader.extended_fuses=0xFD
mega2560.bootloader.path=stk500v2
mega2560.bootloader.file=stk500boot_v2_mega2560.hex
mega2560.bootloader.unlock_bits=0x3F
mega2560.bootloader.lock_bits=0x0F
mega2560.build.mcu=atmega2560
mega2560.build.f_cpu=16000000L
mega2560.build.core=arduino
mega2560.build.variant=mega
Can you help me?
Thanks in advance.
Some controllers like the AT*X*MEGA series support individual flash sections that can be programmed/erased independently. However, with the ATMEGA2560 this is not possible.
One way would be to concatenate the .hex files as part of the build process. This can be achieved with some modifications to the makefile.
Something similar to this
all: $(TARGET).hex
srec_cat bootloader.hex -intel $(TARGET).hex -intel -o combined.hex -intel
Flashing the ´combined.hex´ would then include both, main application and boot loader. There is a related discussion on AVRFreaks.
Regarding the fuses, you just have to make sure that the boot loader (address) stays configured as the entry point.
EDIT: You can use this fuse bit calculator to verify fuse settings. Select your device and make sure "Boot Reset vector Enabled (default address=$0000); [BOOTRST=0]" is enabled with your current high fuse value.
You currently use
mega2560.bootloader.high_fuses=0xD8
so that seems fine.