Configuring ATtiny85 to use external 8MHz oscillator? - arduino

I am using an ATtiny85 8 pin AVR to send AT commands to an RN42 Bluetooth module. I am programming the AVR using an Arduino as an ISP therefore writing the code in the Arduino IDE, using the SoftwareSerial library as the AVR has no UART port.
To ensure accurate clocking out of the data I have added an 8MHz oscillator (LFSPXO018045) on pin 2 but I'm not sure how to make sure the AVR is using this and not just defaulting to the internal osc. I've seen mention of "Fuses" that need setting? Is there any in-code things I need to do like set a register flag or any pre-scalers?
Here is the Eagle circuit and option I found so far but don't know if there's anything else that needs doing too?: PCB & IDE
By the way this is my first question so please be lenient if I've missed something!

Clock settings of AVR MCUs can be changed via using the dedicated Fuse bits. These Fuse bits unfortunately cannot be modified from software. The only way to program the Fuse bits is either using a JTAG programmer or an ISP programmer (like: USBasp, AVRISP mkII or you can use an Arduino as an ISP programmer with the right sketch on it).
This AVR Fuse calculator tool can be used to determine what settings and Fuse values you need to program.

Related

Is it possible to factory reset an arduino from hardware to remove bad user code?

I was troubleshooting why Serial1 was always throwing undefined errors in sketches I was trying to run when I found a solution posted online for a slightly different board that suggested this line:
HardwareSerial Serial1(2);
I uploaded it and now the Arduino doesn't show up in the IDE, did I remap it's serial communications? Why is this possible!
Is there any hardware factory reset option available on these boards? Did I just brick my device?
edit: It seems the STM32Cube programmer app can be used to communicate with the device but I'm not sure where to get the original firmware to flash. https://imgur.com/a/LbiHenf
Assuming from the tag in your question, I guess you have an STM32 – (BluePill) Development Board (STM32F103C8).
If you think that your board is not handling serial communication properly then you might consider burning bootloader to your board. This will reset the complete configuration of your board.
There are many ways in which you can burn bootloader to your board.
Using another Arduino board like Uno / Nano / Mega
Using an FTDI USB to TTL Serial Adapter.
You might want to go through tutorials list below:
Getting Started with STM32 using Arduino IDE: Blinking LED
Programming STM32F103C8 Board using USB Port

PWM/PPM Output misses some edges

I am using ESP8266 (NODEMCU 3.0 or something) to make a quadcopter. Ive connected ardu pro mini to RC receiver so I am reading PPM values from it. Pro mini sends data with tx to ESP8266. ESP reads it with software serial with 115200 baudrate. I am communicating with MPU9255 (Waveshire) via I2C either.
My problem is that I cant fully controll my brushless motors. When I was using arduino instead of ESP8266, servo library was the best and reliable. But ESP's servo library is different, since its not AVR, and problems occurs. First of the servo library didnt want to work on most frequencies. I mean default is 50Hz (20000uS) and in this state ESC of motors did armed but unfortunatelly when changes was fast and short (1250-> 1370 -> 1250) it did miss that change like nothing happnd... This makes my D value in PID controller useless...
Sometimes on 100Hz freq all was working fine, but sometimes not...
When Ive started to use analogWrite only 500Hz was working fine, rest of freq didnt want to arm ESCs.
PS. I am using 3.3V to 5V converter for PPM/PWM pins so I am sure that the signal is fine for ESCs.
PS2. I dont have any osciloscope unfortunately.
The ESP82266 present on your module is a RF transceiver integrated circuit that can handle WiFi communication, both configured as a slave to a microcontroller such as the ones present on various Arduino boards, or as a standalone chip by having it's on-board Tensilica L106 32-bit processor programmed via an external SPI flash memory. If used as a slave, the communication between, for example, an Arduino an the ESP82266 can be done using different protocols such as SPI / SDIO or I2C / UART interfaces. Googling a comprehensive Tensilica L106 user guide on the internet doesn't seem an easy task, and it looks as if some people have already failed to find it. If you're seeking to add Wi-Fi capabilities to your quadcopter the solution I suggest is having the Arduino take control over the servos, motors, etc. and hand off messages via SPI to your ESP82266 module. If this isn't the answer you are looking for, please try to be clearer about it, maybe find someone to do as an English translator for you.
However, if this is what you're concerned about, and you would like to use the ESP82266 module as as standalone solution, please link its built-in processor datasheet and the relevant parts of the quadcopters code that might need debugging.

Upload a HEX firmware to Arduino board

is it possible to upload a firmware to an ATMEGA328P aka Arduino Uno using a serial terminal like Putty or Coolterm?
I know that the Arduino is ready to receive a new firmware after a reset over USB, does the IDE (and avrdude) makes something different other than echoing the binary hex file over serial port?
Thanks
Theoretically, yes. It would be awkward, and you'd need to be able to send and receive arbitrary bytes within a strict time limit, before the bootloader gives up waiting, but you could do it.
The most common bootloaders for the atmega328 use Atmel's STK500 protocol, originally designed for their own AVR development boards but widely used elsewhere (such as on the Arduino). Documentation for this protocol can be found here.
Note that Optiboot, used on modern Arduinos, implements only a subset of this protocol.

Use Arduino board as regular AVR microcontroller

I want to use ATmega2560 MC, but it manufactured only as surface mount IC which means i must make PCB to use it. I searched for a per-made kit and found Arduino Mega R3 board contains the desired MC. (It contains less I/O pins but that's OK for now). Can i implement my code (without any arduino code) in this board? or should i modify it to work with Arduino, also if it runs in the board will it be the same as normal IC or there will be differences in speed.
The MCU in the Arduino Mega2560 is a stock ATmega2560. There is no need to use the Arduino libraries to program it and no need to use the Arduino tools to communicate with it; avr-gcc and avrdude will work with it as normal. Note that you will need to select the appropriate programmer/protocol in avrdude for the bootloader programmed on the chip if you want to program it via serial rather than ISP.

The SoftwareSerial Library of Arduino, why it needs PCINT (pin change inturrupt feature.)?

The SoftwareSerial Library of Arduino don't work with clones made of ATMEGA32 as this do not have PCINT feature. How serial communication is linked with PCINT? can the INT pins of ATMEGA32/16 be someway used by the modification of SoftwareSerial.cpp file?
Prior to IDE 1.0.+ the SoftwareSerial used to be a polling of the Rx Pins. This was blockin, requiring constant checking the service of the RX and limited the quality of the baud rate. Since NewSoftSerial replaced the former older Polled SoftwareSerial, using PCint's. Which creates an interrupt on the change of the RX Pin and then checks the time. This is no longer blocking and better emulates the Hardware Serial port, require less (none) servicing (or polling).
One can go back to the older IDE's SoftwareSerial from before 1.+ and attempt to either port it forward or try to use the ATmega32 in the older IDE. I thought I had seen a DEFINE switch somewhere that would allow it to run in polled mode. But I am unable to find it in current releases. Likely did not make it into the released IDE.
Or you can try to find an alternative to SoftwareSerial. Such as tinyserial Where I see that dates back to 2010 and will likely need some updating. Especially on 1.5.8. May have better luck trying it on 1.0.6

Resources