Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[ARM] First question in this forum of mine:stm32f103C8T6 - Controlling a stepper motor via DM422C (Digital Stepping Drive)

TIMBO 2023

Newbie
Joined
Nov 20, 2023
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
43
(1) Could you check some code-passages in ASSEMBLER ARMv7 for me? I marked relevant semantic lines with an arrow, -> .

(2) Is there a common understanding of programming regarding definitions and declarations, sub-programmes etc.? Do you know a fundamental programmers book beside the official documentation for ARMv7?

(3) I need to pulse a signal on PA2 - there I need support from you - for a clear signal to a configured PA2 ...

IMG_20231108_145026_719_DIS-min.jpg


Code:
 .syntax unified

  .text
  .global __main
  .global function
  .thumb_func

  .equ  RCC_BASE,  0x40021000
  .equ  RCC_APB2_ENR,   0x40021018       // STM32f103C8T6 - Adresse von RCC_APB2ENR - 0x18

  .equ  GPIOC_BASE, 0x40011000      // GPIOC-Basisadresse nach "memory-map", Datenblatt
  .equ  GPIOC_CRH,  0x40011004      // GPIOC-BASE + 0x04 ist das Konfigurationsregister

  .equ  GPIOA_BASE, 0x40010800
  .equ  GPIOA_CRL,  0x40010800

  .equ  GPIO_ODR,   0x4001080C

  .equ  GPIOCEN, 1 << 4     // Seite 141, Referenz-Dokumentation
  .equ  GPIOAEN, 1 << 2     //

  .equ  CRH_OUT_SET_1,  0 << 23
  .equ  CRH_OUT_SET_2,  0 << 22
  .equ  CRH_OUT_SET_3,  1 << 21
  .equ  CRH_OUT_SET_4,  0 << 20 // Von unten nach oben: MODE1, MODE0, CNF1, CNF0 festlegen - (Referenz-Handbuch, Seite 161)

  .equ  CRL_OUT_SET_1_PA4,  0 << 19
  .equ  CRL_OUT_SET_2_PA4,  0 << 18
  .equ  CRL_OUT_SET_3_PA4,  1 << 17
  .equ  CRL_OUT_SET_4_PA4,  0 << 16

  .equ  CRL_OUT_SET_1_PA3,  0 << 15
  .equ  CRL_OUT_SET_2_PA3,  0 << 14
  .equ  CRL_OUT_SET_3_PA3,  1 << 13
  .equ  CRL_OUT_SET_4_PA3,  0 << 12

  .equ  CRL_OUT_SET_1_PA2,  0 << 11
  .equ  CRL_OUT_SET_2_PA2,  0 << 10
  .equ  CRL_OUT_SET_3_PA2,  1 << 9
  .equ  CRL_OUT_SET_4_PA2,  0 << 8  // Von unten nach oben: MODE1, MODE0, CNF1, CNF0 festlegen - Konfiguration für PA2, PA3, PA4 einstellen


  .equ  LED_BLUE,   1 << 13 // PC13 - Programm-Kontroll-LED

  .equ  PA2_PUL,    1 << 2
  .equ  PA3_DIR,    1 << 3
  .equ  PA4_ENA,    1 << 4

  .equ  DELAY_TIME, 1000000


//------------------------------------------------------------------------------------------------
  __main:

  // Setzen der Uhr im Programm
  LDR   R0,=RCC_APB2_ENR
  LDR   R1,[R0]
  ORR   R1,GPIOAEN
->  ORR R1,GPIOCEN
  STR   R1,[R0]         // Absatz beschreibt das Freischalten der Uhr mit dem Bus für Port A und C

  LDR   R0,=GPIOC_CRH
  LDR   R1,[R0]
  LDR   R2,=(CRH_OUT_SET_1|CRH_OUT_SET_2|CRH_OUT_SET_3|CRH_OUT_SET_4)

  ORR   R1,R2

  STR   R1,[R0]         // Konfiguration-Register setzen

  LDR   R2,=GPIO_ODR    // ODR-Register wird in R2 geladen, PROGRAMM-KONTROLL-LED

  LDR   R4,=GPIOA_CRL
  LDR   R5,[R4]
->  LDR R6,=(CRL_OUT_SET_1_PA2|CRL_OUT_SET_2_PA2|CRL_OUT_SET_3_PA2|CRL_OUT_SET_4_PA2|CRL_OUT_SET_1_PA3|CRL_OUT_SET_2_PA3|CRL_OUT_SET_3_PA3|CRL_OUT_SET_4_PA3|CRL_OUT_SET_1_PA4|CRL_OUT_SET_2_PA4|CRL_OUT_SET_3_PA4|CRL_OUT_SET_4_PA4)

  ORR   R5,R6

  STR   R5,[R4]         //  Konfigurations-Register setzen

  LDR   R6,=GPIO_ODR    // ODR-Register wird in R6 geladen, SCHRITTMOTOR

->  MOV R5,#PA3_DIR
  STR   R5,[R6]
->  MOV R5,#PA4_ENA
  STR   R5,[R6]


  function:

    Blink:

    MOV R1,#LED_BLUE
    STR R1,[R2]

->    MOV   R5,#PA2_PUL
    STR R5,[R6]

    LDR R3,=#DELAY_TIME

    BL  delay1

    MOV R1,#0
    STR R1,[R2]

    MOV R5,#0
    STR R5,[R6]

    LDR R3,=#DELAY_TIME

    BL  delay1
    B   Blink

    delay1:
    SUBS R3,R3,#1
    BNE delay1   // BNE, BX
    BX  LR
 
Hello!

(1) Could you check some code-passages in ASSEMBLER ARMv7 for me? I marked relevant semantic lines with an arrow, -> .

Check and do what? And first, what's the problem? If I check this:
-> ORR R1,GPIOCEN
What is it supposed to do, and what does it NOT do?

(2) Is there a common understanding of programming regarding definitions and declarations, sub-programmes etc.? Do you know
a fundamental programmers book beside the official documentation for ARMv7?

I will suppose that "official" here means documentation published by the chip maker.
Official documentation is usually not meant to teach you how to program, whatever the language.
The maker assumes you know how to program.

(3) I need to pulse a signal on PA2 - there I need support from you - for a clear signal to a configured PA2 ...

What is a clear signal?
I mean: if you ask me to configure a 50% PWM signal at 10 kHz, I can do something although I wouldn't do it in assembler.
Now I can't figure out what a clear signal might be.
Now what's the problem of your signal in the current version of your source code?
-> No signal at all, always low / always high
-> There is some signal, but the frequency is not what I meant to use
-> There is some signal, but its amplitude is not good / etc, etc...


Dora
 
Hi,

is it a school project?

I´ve never used assembler on ARM. Thus I can´t help you with coding.

I guess some description text is not translated correctly.
For example:
The descriptions says "Uhr", but indeed I guess it should rather be "Takt". I´d still prefer the English word "clock".

Klaus
 
Salve DORA,



(1)
I would like to "open" with this code line the bus periphery for GPIOC.

(2)
I am just searching for a fundamental book of assembler programming ARMv7 (32-bit) beside the official documentations. I am open for hints.

(3)
Most important for me:

Attached you will find the datasheet of the digital stepping drive with the pulse-signal restrictions...

My simple thought was, to send only a high value to PA2 to make my first stepper-motor rotation ... but it does not look so simple ...
I am fine, when you would give a code-snippet in our discussion.

Then we can analyze it together ...



TIMBO 2023
from SS
(Scientific Society)

Bildschirmfoto vom 2023-11-21 01-20-07.png
 
Hello KLAUS,


thank you for your furthering "qualified and certified comment" about "clocks" in common and as idea input perhaps for future programming ambitions.

We just made first directions into "standardize ideas" for comments, declarations and programming routines in common programs.
But you can't see it in this simple ASSEMBLER-snippet.
Operators are so in a better position to read and to work with program-codes especially in the engineering sector.
But through the individual character - often academical character - it is not so easy to implement standard programming work into the high academic programming sector.


Have a nice day and multicultural greetings from the future µc-programmer section
TIMBO 2023
SS (Scientific Society)
 
Hello!

(1) I would like to "open" with this code line the bus periphery for GPIOC.

You know, it's a real pain to have to pit every sentence you write.

Again, Ok, you want to open something. Maybe put GPIOC to output mode?

Now that's fine. But:
- What are you expecting to observe by writing the code?
- What do you actually observe?

I know that setting a GPIO to output mode does not translate to action, but
you are asking to verify this line. What do you want us to do? I'm not paid to
do that, so at least, explain your experiment, explain what goes wrong, if possible
at what code line it does go wrong, etc, etc...

I am just searching for a fundamental book of assembler programming ARMv7 (32-bit)
beside the official documentations. I am open for hints.

From my experience (your mileage may vary), programming in asm is usually
10% documentation and 90% experimentation. If you ask, all those who have learned
ARM7 assembly can tell you which book they used, but usually one uses a single book,
so you will probably get as many book references as therer are asm coders here.
What works best for me is getting examples.

Beside this, I don't spend time with assembler anymore. Most of the modern compilers
are as efficient as assembler, and on top of that, C or C++ is a lot more portable,
once the drivers are written. Engineers in their 60s, 70s may disagree.

My simple thought was, to send only a high value to PA2 to make my first stepper-motor
rotation ... but it does not look so simple ...
I am fine, when you would give a code-snippet in our discussion.

Bis repetita placent:
Can you tell us what goes wrong? You have programmed some code, what happens
when you execute it? What does not look so simple? From my point of view, it is
very simple. So what does your motor do?

I am fine, when you would give a code-snippet in our discussion.

First try to behave like an engineer:
- Explain what you did.
- Explain what goes wrong (don't say it doesn't work, it doesn't look simple).
For example, I have setup the port in output mode at line
I try to set the port C, bit 2 high at line xx (PORTC |= 0x04) ;
On the oscilloscope, it stays low
Etc, etc...

NB: That's my last mail if you don't publish real technical description of what
you did and what doesn't work. With scope output if you have one, or the state
of an LED that you set on PORTC's second bit.

Dora
 
Additional hints:

definitions like
[ .equ PA2_PUL, 1 << 2 ]
are meant to wrting code more easy.
I understand that you want to show that this signal is at PA2 ... but indeed for wrting the code this information is not immportant.
But in case you later move this pin to PB4 ... you neeed to change every line in code where you used this name.

Its better to use
Code:
// Stepper wiring:
  .equ  PA2_PUL,    1 << 2     // PA2, PULSE output
  .equ  PA3_DIR,    1 << 3     // PA3, rotation direction output, 0=CW, 1=CCW
  .equ  PA4_ENA,    1 << 4    // PA4, Driver enable output, 0 = enabled

* So you still have the information that it´s on PA2 ... This information is exactly where you need it: at the top of the file.
* if you change the wiring, you need change jsu one line: where the define is.
* if you look at the code after years

****
As others mentioned: It´s by far not clear waht information you expect from us. Neither it´s clear what function you expect from your code.

So we have to guess (And many engineers (like me) don´t want to guess).
I guess you expect the stepper to rotate. But the stepper has it´s name because it only makes a "single step" per pulse.
If you want a stepper to rotate, you continously need to send pulses. The pulse frequency determines the RPM.


Klaus
 
(1) NO
(2) NO
(3) NO, I lough about the "oscilloscope", it is like the "clock" (?!) support in words in your answers...

That is not my kind of understanding and factually discussion base...


Have a nice day ...
TIMBO 2023
 
Hello!

(1) NO
(2) NO
(3) NO, I lough about the "oscilloscope", it is like the "clock" (?!) support in words in your answers...

Here again. We don't know whom you are replying to. We don't even know what was (1) and (2) because there
were no numbers in Klaus' mail and in mine either. The 3rd indicates it might be a reply to me, so you
may explain why you are laughing. The oscilloscope is the 1st equipment you could consider to debug hardware.
Beside this, I don't understand what you mine by "it is like the clock support in words in your answers".
Are you using some kind of automatic translation software?
If it's not your "kind of understanding", that's too bad for you.

So again: you want to keep all your info? Good! So try to figure out by yourself. I don't understand why you are
asking. You might consider learning how to communicate in the first place.

Dora
 
Hi,

You might consider learning how to communicate in the first place.

I did an internet search and found similar forum threads like this, most likely from the same person.

Always same behaviour.
Not giving useful informations leads to not getting useful answers.

I don´t see any progress, thus I leave this thread by saying "good bye and Good Luck for the future" to
the future µc-programmer section
TIMBO 2023
SS (Scientific Society)

Klaus
 

LaTeX Commands Quick-Menu:

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top