8

This is a X->Y problem. Here is a solution for X: Bit 3 of high fuse of the ATmega328p controls if EEPROM memory is preserved through the chip erase. You can change the high fuse setting in boards.txt. Restart the IDE to apply the new setting. The fuses are written when you select the "burn bootloader" option in the Arduino IDE.


7

The main difference is the bit before the -. That is, the 328 vs the 328P. The "P" there denotes "Picopower" which allows the chip to run at very low power consumptions. Basically the P version is a more modern version of the non-P chip. There are probably other internal differences too but you will have to check the datasheets thoroughly for those. ...


4

Schematic corrections: Missing 0.1uF caps on VCC, AREF pins. AREF pin connected to 5V - don't do that. It will connect internally using the ADC Mux if used. C1, C6 need to be 22pF as noted earlier. Xtal and C1, C6 should be right next to the chip as noted, with no traces going under the xtal. Board should have Gnd plane anywhere there is not a trace. ...


3

In the case, that this is a school assignment and you actually have to program directly in assembler, you probably don't want to directly convert your C++ sketch. It will generate way more assembler code, than is really necessary for alternatively blinking two LEDs (for example digitalWrite() contains not only the actual writing to the corresponding pin ...


3

The compiler cannot detect a missing ISR since it is very difficult, in the general case, to tell whether any particular interrupt-enable bit has been set by the program. The avr-libc library does indeed provide a “catch-all” ISR and, as stated by the manual, the default action is to reset the device by jumping to the reset vector. If you don't like ...


3

Not sure if this will fix your problem, but this is a major error: char buf1[8], buf2[6]; sprintf(buf1, "%08lu", myvote.mydate); sprintf(buf2, "%06lu", myvote.mytime); Take a look at sprintf function reference A terminating null character is automatically appended after the content. So, the text buffers are too small. It should be at least: char ...


3

The bits within a byte are numbered 0 through 7 from right to left. The rightmost (least significant) is bit 0, next is bit 1... and the leftmost (most significant) is bit 7. The expression _BV(3) builds a byte where bit 3 is set (is 1) and all other bits are clear (are 0). In binary it looks like this: position: 7 6 5 4 3 2 1 0 bit value: 0 0 ...


3

You should be using a P-channel MOSFET (which is set to be normally OFF with a pull-up resistor) and the Arduino is responsible for keeping it on: simulate this circuit – Schematic created using CircuitLab In this schematic M1 is normally off. You press and hold SW1 and the Arduino gets power. The first thing it then does is turn on the GPIO. That ...


2

Can I manually jump to an ISR regardless of its "normal" trigger? This should be possible, but is probably not the best solution. This is certainly an X -> Y problem, so I'm open for other approaches. It would seem you are using the timer in CTC mode. In this mode, when you write to OCRxA, the register is updated immediately, which leads to the ...


2

No, this is not possible. The datasheet of the ATmega328P states it has: 8-channel 10-bit ADC in TQFP and QFN/MLF package 6-channel 10-bit ADC in PDIP Package If you want to use a bare chip, it won't be possible with a PDIP package.


2

Use the https://github.com/MCUdude/MiniCore for ATmega328. It has Boards Manager installation. Choose the right options in Tools menu for your ATmega328. First burn the bootloader using programmer or "Arduino as ISP". Then you can do serial upload as usual. You can put the ATmega328 on Uno if you want.


2

There are three die types: 328 328P 328PB all have different signature bytes which may or may not impact loading code into them. Generally tho the programming software needs to know which part type is being used, at a minimum for installing bootloader code. Serial downloading may end up ignoring the signature bytes of a bootloaded part. They can be had ...


2

You wrote: Using [...] the atmega's hardware pwm is not very suitable because I need two 50/50 square waves with a phase difference of pi I believe hardware PWM is the best solution to your problem. The PWM outputs can be set to either “inverting” or “non-inverting” mode. Set the two channels of a single timer to the same duty cycle, with one in non-...


2

what exactly is it that makes a simple function like digitalWrite() so damn slow??! Why isn't it just a wrapper function for direct port manipulation? Well, it can take a variable as an argument. And the contents of the variable have to be looked up in a table to see which port and which bit. If you use the DigitalWriteFast library then that turns your ...


2

I can see you are on Linux so I won't give you instructions for using AVR Studio - but do know that if you have access to a Windows machine that is another option you could try. I can't tell you exactly why it is not working through the Arduino IDE - it could be that the settings are not set correctly or any number of reasons. What I can say is that it is ...


2

There are also a couple of ways of including assembler code right inside your Arduino IDE. By including the assembler in the Arduino IDE, the assembler source is assembled and linked into your project and uploaded to your Arduino from within the IDE - just like any other program. This makes it easy to get started with Assembler while still retaining the ...


1

To upload compiled code (.hex) to a bare atmega which doesn't have a bootloader installed you can use ISP. As this stands for in-system-programming you don't have to flash the chip before assembly, but you can flash it in-system, so when already soldered onto your pcb. There actually is no need for those adapters like shown in your first picture, which often ...


1

It "needs" to be done in assembly as an assignment, right? Otherwise you would "want to learn" assembly. What I suggest you do is change the C program to use port manipulation, for example: void setup() { DDRB |= 0b00100000; // D13 to output mode } void loop() { PORTB |= 0b00100000; // turn on D13 delay(2000); PORTB &= ~...


1

A new chip cannot be programmed in that manner until it has the Bootloader installed. The Bootloader starts after a reset and monitors the serial interface to see if something is attempting to download code via the serial port. Selecting a Programmer has no effect on serial download, that only comes into play when Programming via the SPI pins SCK/MOSI/MISO/...


1

The interrupt vector table is provided by the C runtime. It is not normally intended to be overridden by user code. You can, however, do it, if you replace the whole C run time by your own, and compile your sketch with the -nostartfiles option. I have played this game once I was trying to accurately assess interrupt latencies. See the details in this answer ...


1

Use the "Upload using programmer" in Sketch menu to upload a sketch over ISP warning, it deletes the bootloader


1

The problem is most likely EMI (electromagnetic interference) from the switching of the inductive load by the relays. The fact that you have your setup on a breadboard means that each and every pin of the ATMega328 is connected to a little antenna. That massively increases its susceptibility to falling prey to EMI. Add to that the fact that there is ...


1

I've actually done some tinkering with this sort of thing, or alternatively how to ensure previous EEPROM (or similar) settings are formatted on upload of a new sketch. There are two values (C macros, in this case) that are baked into a program when it is compiled (for Arduino, the program is recompiled on each upload) that can be used to tell if the ...


1

The Dimmer library doesn't support Atmega128/164/16/32. It has #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) #define DIMMER_TIMER 4 #elif defined(__AVR_ATmega32U4__) #define DIMMER_TIMER 3 #else #define DIMMER_TIMER 2 #endif For the Atmega128/164/16/32 it will use timer 2. The main errors are: 'OCR2A' was not declared in this scope '...


1

Don't use SoftwareSerial in esp8266. Connect the 328p's SoftwareSerial pins to Serial interface pins of the esp8266. ESP8266 has second Serial interface named Serial1. It has only TX (io 2), but it is enough for debug prints. To change the firmware or sketch in esp8266 you can use ArduinoOTA library, but you should be ready to disconnect the esp8266 Serial ...


1

Few things to consider : Each variable in your program take memory, try to use the smallest datatype ( don't use a float if you need an int for example). Eliminate strings Reduce the usage of array Reduce your code size by using function for redudant task Avoid using digital and analog red/write. Use port manipulation instead (link here) Modify library to ...


1

your HTTP request is incomplete. it should be String cmd = "GET /greencare/login.php?product_id=123456 HTTP/1.1\r\nHost:alirezaabrishami.ir\r\n\r\n" if the wen server host has more hostnames for the same IP address, the Host header is used on HTTP server to direct the request to the right web application


1

The antenna is too close to the module. You probably used the spiral antenna. Try using the PCB antenna with long (10cm) cable. Had the same problem, solved with the antenna.


1

Concerning your questions about clock division settings: have a look at this pretty tool, it gives you a avrdude query for setting fuses (take care!). The CKDIV8 bit of the low fuse is set by default, so an AT328p will run at 1MHz, clearing this bit will result in 8 MHz. When flashing you should never override any checks as this may damage/lock your chip. ...


1

Easy Very Low Power BLE in Arduino covers using Arduino IDE and nRF52832 chips to code very low power projects, i.e. <100uA continuously, waiting for connection or while connected and sending data. The <100uA current is at max tx power and can be further reduced by reducing Tx power and increasing the advertising and connection intervals. Ignoring ...


Only top voted, non community-wiki answers of a minimum length are eligible