<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-15">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi, while playing arround I found a strange behaviour that seems to
have to do with the fact that writes to bitpacked records are byte
aligned.<br>
<br>
Here are the details:<br>
<br>
I have create a bitpacked record set for the GPIO Registers of the
processor. On Port D of the processor I have 16 LED's, one for each
bit.<br>
<br>
TGPIO_ODR_bits = bitpacked record<br>
ODR0 : 0..1;<br>
ODR1 : 0..1;<br>
ODR2 : 0..1;<br>
ODR3 : 0..1;<br>
ODR4 : 0..1;<br>
ODR5 : 0..1;<br>
ODR6 : 0..1;<br>
ODR7 : 0..1;<br>
ODR8 : 0..1;<br>
ODR9 : 0..1;<br>
ODR10 : 0..1;<br>
ODR11 : 0..1;<br>
ODR12 : 0..1;<br>
ODR13 : 0..1;<br>
ODR14 : 0..1;<br>
ODR15 : 0..1;<br>
RESERVED : 0..65535;<br>
end;<br>
<br>
When I now access the bits via:<br>
<br>
GPIOD_B.ODR.ODR0 := 0;<br>
GPIOD_B.ODR.ODR0 := 1;<br>
<br>
not only the LED for ODR0 lights up, also the one connected to ODR8
!!??!!<br>
<br>
When I access the Port without the bitset:<br>
GPIOD.ODR := 0;<br>
GPIOD.ODR := 1;<br>
only the LED attached to ODR0 lights up.<br>
<br>
Looking at the assembler code I see the following:<br>
<br>
.Ll5:<br>
ldr r0,.Lj19 //Code for GPIOD_B.ODR.ODR0 := 0;<br>
<b>ldrb</b> r0,[r0]<br>
bic r0,r0,#1<br>
and r0,r0,#255<br>
ldr r1,.Lj19<br>
<b>strb</b> r0,[r1]<br>
.Ll6:<br>
ldr r0,.Lj19 //Code for GPIOD_B.ODR.ODR0 := 1;<br>
<b>ldrb</b> r0,[r0]<br>
orr r0,r0,#1<br>
and r0,r0,#255<br>
ldr r1,.Lj19<br>
<b>strb</b> r0,[r1]<br>
.Ll7:<br>
mov r0,#0 //Code for GPIOD.ODR := 0;<br>
ldr r1,.Lj19<br>
<b>str</b> r0,[r1]<br>
.Ll8:<br>
mov r0,#1 //Code for GPIOD.ODR := 1;<br>
ldr r1,.Lj19<br>
<b>str</b> r0,[r1]<br>
<br>
<br>
The strb command seems to be the problem, documentation from STM
states:<br>
<br>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-15">
<span style="font-size: 10.000000pt; font-family: 'Helvetica'">Each
I/O port bit is freely programmable, however the I/O port
registers have to be accessed
as 32-bit words (half-word or byte accesses are not allowed).
</span> <br>
<br>
So, is there some way to make the bitset operations word-aligned?
Are there any good reasons for not doing so?<br>
<br>
<br>
Michael<br>
<br>
<title>STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and
STM32F107xx advanced ARM-based 32-b</title>
<br>
<br>
<br>
<br>
</body>
</html>