From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!proxad.net!feeder1-2.proxad.net!cleanfeed3-a.proxad.net!nnrp4-1.free.fr!not-for-mail From: =?iso-8859-1?b?RnLpZOlyaWM=?= Praca Subject: Re: Representation clauses and side-efects on STM32F411 ravenscar runtime Newsgroups: comp.lang.ada References: <55bddbe2$0$3384$426a74cc@news.free.fr> User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Date: 02 Aug 2015 14:52:15 GMT Message-ID: <55be2e9e$0$3318$426a74cc@news.free.fr> Organization: Guest of ProXad - France NNTP-Posting-Date: 02 Aug 2015 16:52:15 CEST NNTP-Posting-Host: 94.71.68.35 X-Trace: 1438527135 news-3.free.fr 3318 94.71.68.35:56291 X-Complaints-To: abuse@proxad.net Xref: news.eternal-september.org comp.lang.ada:27326 Date: 2015-08-02T16:52:15+02:00 List-Id: Le Sun, 02 Aug 2015 10:40:33 +0100, Simon Wright a écrit : > Frédéric Praca writes: > >> I was expecting the compiler (GNAT GPL 2014 (20140331) from Adacore >> under Linux x64) to handle all and, or and xor operations by itself for >> such kind of representation. Was I wrong ? > > I think you should declare Baud_Rate_Register as Volatile in any case. Yes, I've done this later in the code defining the whole register : USART1 : USART_Registers with Volatile, Address => System'To_Address (USART1_Base); see https://github.com/FredPraca/ravenscar-sfp-stm32f411-nucleo/blob/ master/ravenscar-sfp-stm32f411-nucleo/adainclude/s-stmusa.ads > But there was a discussion here about this recently; Volatile doesn't > guarantee any sort of full word access (or half word; how would the > compiler know?). I thought that Volatile was only about avoiding caching data and tell to the compiler that the variable would be modified externally. > AdaCore recently included aspect Volatile_Full_Access[1] which is > supposed to do what you want. Ok, thanks for the pointer. > GNAT GPL 2015 recognises this aspect; FSF GCC 5.1.0 doesn't (I haven't > looked into 5.2.0 yet, but AdaCore typically only fix serious bugs in > subreleases). > > Failing that, the recommended technique to change one component is to > use a temporary: > > declare > BRR : Baud_Rate_Register := USART2.BRR; > begin > BRR.DIV_Mantissa := 16#445#; USART2.BRR := BRR; > end; Great ! I'll try this. > but of course if you're changing all the components your whole record > assignment will do the trick. > > In any case, a whole record assignment is better practice, because it > means the compiler won't let you forget to assign a component. Totally agree, I like this kind of help from the compiler. > [1] > http://www.adacore.com/developers/development-log/NF-74-M715-002-gnat/