Worauf bezieht sich das? Auf FPC? Dazu sind zum Controller passende Register-Definitions-Units notwendig.
Auf die GPIO-Zugriffe des AVR. http://wiki.freepascal.org/AVR_Embedded_Tutorial_-_Simple_GPIO_on_and_off_output/de
Worauf bezieht sich das? Auf FPC? Dazu sind zum Controller passende Register-Definitions-Units notwendig.
Code: Alles auswählen
PORTB : byte absolute $00+$25; // Port B Data Register
DDRB : byte absolute $00+$24; // Port B Data Direction Register
PINB : byte absolute $00+$23; // Port B Input Pins
Code: Alles auswählen
var
mem : array[0..$7fff-1] of byte absolute $0;
begin
DDRB := DDRB or (1 shl BP5);
repeat
// PORTB := PORTB or (1 shl BP5);
Mem[$25] := Mem[$25] or (1 shl BP5);
mysleep(sl);
Mem[$25] := Mem[$25] and not (1 shl BP5);
// PORTB := PORTB and not (1 shl BP5);
mysleep(sl);
until 1 = 2;
end.
Code: Alles auswählen
void loop() {
// Pin PC13 einschalten
// gpio_write_bit(GPIOC, 13, 1);
// GPIOC->regs->BSRR = (1U << 13) << (16 * 0l);
GPIOC->regs->BSRR = 0b10000000000000;
delay(100);
// Pin PC13 ausschalten
// gpio_write_bit(GPIOC, 13, 0);
// GPIOC->regs->BSRR = (1U << 13) << (16 * 1l);
GPIOC->regs->BSRR = 0b100000000000000000000000000000;
delay(100);
}
Macht eigentlich nicht viel Sinn, aber ich will den STM32 Kennenlernen.
Code: Alles auswählen
begin
PortC.BSRR:=%10000000000000;
end.
Ist wohl doch nicht so einfach.FPC für arm-embedded bauen:
make clean all OS_TARGET=embedded CPU_TARGET=arm SUBARCH=armv7m
Code: Alles auswählen
system.pp(325) Error: Assembler arm-embedded-as not found, switching to external assembling
Code: Alles auswählen
void loop() {
(*(char *)(0x25)) |= 0b100000;
delay(1000);
(*(char *)(0x25)) &= ~0b100000;
delay(100);
}
Code: Alles auswählen
void loop() {
// gpio_write_bit(GPIOC, 13, 1);
// GPIOC->regs->BSRR = (1U << 13) << (16 * 0l);
// GPIOC->regs->BSRR = 0b10000000000000;
(*(__uint32_t *) (0x40011000 + 16)) = 0b10000000000000;
delay(100);
// gpio_write_bit(GPIOC, 13, 0);
// GPIOC->regs->BSRR = (1U << 13) << (16 * 1l);
// GPIOC->regs->BSRR = 0b100000000000000000000000000000;
(*(__uint32_t *) (0x40011000 + 16)) = 0b100000000000000000000000000000;
delay(10);
}
Code: Alles auswählen
typedef struct gpio_reg_map {
__IO uint32 CRL; /**< Port configuration register low */
__IO uint32 CRH; /**< Port configuration register high */ + 4
__IO uint32 IDR; /**< Port input data register */ + 8
__IO uint32 ODR; /**< Port output data register */ + 12
__IO uint32 BSRR; /**< Port bit set/reset register */ + 16
__IO uint32 BRR; /**< Port bit reset register */
__IO uint32 LCKR; /**< Port configuration lock register */
} gpio_reg_map;
Code: Alles auswählen
Debug demo project for STM32L100C-Discovery board 2018-04-06 mse
-------------------------------------------------
- clone, build and install the texane ST-Link tools:
https://github.com/texane/stlink
see
https://github.com/texane/stlink/blob/m ... mpiling.md
- Download the ARM toolchain:
https://developer.arm.com/open-source/g ... /downloads
extract it to a directory of your choice (<toolchaindir>).
- Download the ST firmware STM32CubeL1:
http://www.st.com/content/st_com/en/pro ... are-scroll
extract it to a directory of your choice (<firmwaredir>).
- Run MSEide.
- 'Project'-'Open'-"blinkerdebug.prj".
- 'Project'-'Options'-'Macros', update <toolchaindir> and <firmwaredir>.
- 'Target'-'Download' in order to flash the program.
- 'Target'-'Continue' in order to run the program.
Have a lot of fun!
Martin
Code: Alles auswählen
Free Pascal demo project for STM32L100C-Discovery board 2018-04-07 mse
-------------------------------------------------------
- clone, build and install the texane ST-Link tools:
https://github.com/texane/stlink
see
https://github.com/texane/stlink/blob/m ... mpiling.md
- Download the ARM toolchain:
https://developer.arm.com/open-source/g ... /downloads
extract it to a directory of your choice (<toolchaindir>).
- Download the Free Pascal ARM-embedded cross compiler:
https://sourceforge.net/projects/mseide ... membedded/
extract it to a directory of your choice (<crossfpcdir>).
- Run MSEide.
- 'Project'-'Open'-"stm32l100c.prj".
- 'Project'-'Options'-'Macros', update <toolchaindir> and <crossfpcdir>.
- 'Target'-'Continue' in order to run the program.
Have a lot of fun!
Martin
Code: Alles auswählen
#include <stddef.h>
#include <stdlib.h>
#define LEDPin 13
void setup() {
GPIOA->regs->CRH = 0x33333333;
GPIOA->regs->CRL = 0x33333333;
GPIOC->regs->CRH = 0x33333333;
GPIOC->regs->CRL = 0x33333333;
}
void loop() {
// GPIOA->regs->BRR = 0B01010101;
// GPIOA->regs->BSRR = 0B10101010;
GPIOA->regs->ODR = 0B10101010;
GPIOC->regs->BSRR = 1 << LEDPin;
// (*(__uint32_t *) (0x40011000 + 16)) = 0b10000000000000;
delay(500);
// GPIOA->regs->BRR = 0B10101010;
// GPIOA->regs->BSRR = 0B01010101;
GPIOA->regs->ODR = 0B01010101;
GPIOC->regs->BSRR = 1 << LEDPin << 16;
// (*(__uint32_t *) (0x40011000 + 16)) = 0b100000000000000000000000000000;
delay(500);
}
Mathias hat geschrieben:Jetzt muss ich mal bei Gelegenheit gucken, ob ich den Cross-Compiler mit deinem Links hinkriege.
Code: Alles auswählen
st-util: error while loading shared libraries: libstlink.so.1: cannot open shared object file: No such file or directory
Code: Alles auswählen
sudo ldconfig
Code: Alles auswählen
Free Pascal Compiler version 3.1.1 [2018/04/07] for arm
Copyright (c) 1993-2018 by Florian Klaempfl and others
Target OS: Embedded
Compiling stm32l100c.pas
stm32l100c.pas(6,13) Warning: Variable "testvar" does not seem to be initialized
Assembling stm32l100c
stm32l100c.pas(9) Error: Assembler arm-embedded-as not found, switching to external assembling
stm32l100c.pas(9) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Code: Alles auswählen
TOOLCHAINDIR /home/acer/Schreibtisch/arm/gcc-arm-none-eabi-7-2017-q4-major/bin
Code: Alles auswählen
TOOLCHAINDIR /home/acer/Schreibtisch/arm/gcc-arm-none-eabi-7-2017-q4-major
Code: Alles auswählen
/home/tux/Schreibtisch/MSEgui_arm/gcc_arm/bin/arm-none-eabi-as
Code: Alles auswählen
TOOLCHAINDIR /home/tux/Schreibtisch/MSEgui_arm/gcc_arm
Code: Alles auswählen
/home/tux/Schreibtisch/MSEgui_arm/gcc_arm/arm-none-eabi/bin
Code: Alles auswählen
gdb server start error 127.
Code: Alles auswählen
/home/mse/test/crossfpc-x86_64_linux_eabi_embedded_3_1_1//lib/fpc/3.1.1/ppcrossarm -Fu/home/mse/test/crossfpc-x86_64_linux_eabi_embedded_3_1_1/lib/fpc/3.1.1/units/arm-embedded/* -Fi/home/mse/test/crossfpc-x86_64_linux_eabi_embedded_3_1_1/lib/fpc/3.1.1/units/arm-embedded/* -Fl/home/mse/test/crossfpc-x86_64_linux_eabi_embedded_3_1_1/lib/fpc/3.1.1/units/arm-embedded/* -Fo/home/mse/test/crossfpc-x86_64_linux_eabi_embedded_3_1_1/lib/fpc/3.1.1/units/arm-embedded/* -g -Tembedded -Cparmv7m -WpSTM32F103X4 -e/home/mse/download/arm/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/bin stm32l100c.pas
Code: Alles auswählen
-e/home/mse/download/arm/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/bin
Code: Alles auswählen
gdb server start error 127.
Code: Alles auswählen
st-util
Code: Alles auswählen
st-util: error while loading shared libraries: libstlink.so.1: cannot open shared object file: No such file or directory
Code: Alles auswählen
sudo ldconfig