22205 views|4 replies

67

Posts

0

Resources
The OP
 

Questions about conditional definitions [Copy link]

#ifndef CONF_SERCOM_0_USART_BAUD //#define CONF_SERCOM_0_USART_BAUD 9600 #if (*(__IO uint8_t*)(((uint32_t)0x44000000))==0x01) #define CONF_SERCOM_0_USART_BAUD 2400 #elif (*(__IO uint8_t*)(SEEPROM_ADDR+15)==0x02 #define CONF_SERCOM_0_USART_BAUD 4800 #elif (*(__IO uint8_t*)(SEEPROM_ADDR+15)==0x03 #define CONF_SERCOM_0_USART_BAUD 9600 #elif (*(__IO uint8_t*)(SEEPROM_ADDR+15)==0x04 #define CONF_SERCOM_0_USART_BAUD 115200 #else #define CONF_SERCOM_0_USART_BAUD 2400 #endif #endif Why does this definition method report an error? "operator '*' has no left operand" This is the error message

This post is from Embedded System

Latest reply

It is really too evil. This is also a long-standing experience. What kind of evil is it that would think of determining the baud rate during compilation?  Details Published on 2018-10-25 00:15

67

Posts

0

Resources
2
 
This method was used for STM32 before. Now that we have changed to atmel studio compiler and ATSAM chip, will this method no longer work?
This post is from Embedded System
 
 

6040

Posts

204

Resources
3
 
The code above is missing a lot of right brackets, but I think this is not the point. The function you want to achieve cannot be achieved by macro definition. Macro definition is processed during the preprocessing period of compilation, and the code you wrote above needs to be judged during the runtime. During the compilation period, the compiler analyzes the program on the PC. How can it know the content in the hardware circuit memory?
This post is from Embedded System

Comments

Oh, I see. Thanks. But I remember I used to operate stm32 like this.  Details Published on 2018-10-23 09:40
 
 
 

67

Posts

0

Resources
4
 
lcofjp posted on 2018-10-23 09:12 The code above lacks a lot of right brackets, but I don't think this is the point. The function you want to implement cannot be implemented by macro definition. Macro definition is in the compilation...
Oh, I know, thank you, but I remember that I used to operate stm32 like this
This post is from Embedded System
 
 
 

7815

Posts

57

Resources
5
 
lcofjp posted on 2018-10-23 09:12 The code above is missing a lot of right brackets, but I think this is not the point. The function you want to achieve cannot be achieved by macro definition. Macro definition is in the compilation...
It is really too evil. This is also a long-standing experience. What kind of evil is it that would think of determining the baud rate during compilation?
This post is from Embedded System
 
Personal signature

强者为尊,弱者,死无葬身之地

 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list