If I understood the AVR instruction manual correctly, the ATtiny 25 can disable the BODlevel2 fuse by software, but when compiling with Studio 7 (version 7.0.132), I get the error "Undefined symbol: BODS & BODSE".
- BODLEVEL fuses are set correctly. L:0x62 H:0xDD E:0xFF
; init brown out detection disable for sleep mode
ldi r23, (1<<BODS)|(1<<BODSE) ; En 2 fois 1- pour autoriser ecriture
out MCUCR, r23 ; Envoyer autorisation ecriture
ldi r23, (1<<BODS)|(0<<BODSE) ; Ecrire valeur a envoyer dans R23
out MCUCR, r23 ; Envoyer R23 dans MCUCR
; init WDT for interrupt mode
ldi r23, (1<<WDCE)|(1<<WDE)
out WDTCR, r23
ldi r23, (1<<WDIE)|(0<<WDE)|(0<<WDP0)|(1<<WDP1)|(0<<WDP2)|(0<<WDP3) ; sec time out WDT interrupt; no system reset
out WDTCR, r23
sei ; global interrupt enable bit is active
L1_INTERIEUR: ; init sleep modes
ldi r23, (1<<SM1) ; Power-down mode
out MCUCR, r23
in r23, MCUCR
ldi r23, (1<<SE) ; sleep mode enabled
out MCUCR, r23 ; put MCU into sleep
L1A_INTERIEUR:
in R15,SREG
wdr
sleep
1 Answer 1
The Microchip Studio uses the GNU toolchain or the XC8 toolchain. Unfortunately you did not tell us, which you use for your project.
The common solution is to include the corresponding header file to let the preprocessor replace the symbols with the defined values:
#include <iotn25.h>
; init brown out detection disable for sleep mode
ldi r23, (1<<BODS)|(1<<BODSE) ; En 2 fois 1- pour autoriser ecriture
; ...
Or to add "iotn25.h" to the dependencies in the "Solution Explorer".
Now you need to make sure that the preprocessor runs before the assembler. Both toolchains behave identically, if you name the assembler source with an uppercase extension of ".S".
The GNU toolchain does this according to its documentation:
You can use the GNU C compiler driver to get other "CPP" style preprocessing by giving the input file a ‘.S’ suffix.
For the XC8 toolchain, the documentation tells us explicitly about this and an interesting option in chapter 8.3.4.1:
The
-x assembler-with-cpp
language option ensures assembly source files are preprocessed before they are assembled, thus allowing the use of preprocessor directives, such as #include and C-style comments with assembly code. By default, assembly files not using the .S or .sx extension are not preprocessed.
Explore related questions
See similar questions with these tags.
cat iotn25.h | grep BODS
in where the toolchain is stalled give me this#define BODS 7
, and#define BODSE 2
.