Python-STM32 serielle Schnitstelle

Gast #5843603
Lesenswert?

Hallo zusammen,

ich möchte Data von Python über serielle Schnitstelle an STM32 µc 
senden, deswegen brauche ich euere Unterstützung. Zum Testen veruschte 
ich '0' an den µc zu schicken, leider hat aber die LED am Board nicht 
geblinkt. Der STM32 Code wird automatisch generiert.

hat Jemand einen Vorschlag ?

danke
Angehängte Dateien:
Gast #5843643
Lesenswert?

11520 war ein Tippfeheler.


Python Code:


import serial #Serial imported
import time #import delay functions

STM = serial.Serial('com33',115200)
time.sleep(0.5)

STM.write('0') #send 0


generated Code:

void Python_22_step(void)
32  {
33    /* UARTRx: '<Root>/UART Rx' */
34    UARTRx_Receive(&UART2_Temp_Buffer[0], 1);/* Blocking */
35    memcpy(&Python_22_B.UARTRx, &UART2_Temp_Buffer[0], 
1*sizeof(uint8_T));/* D0 [1] */
36
37    /* RelationalOperator: '<S1>/Compare' incorporates:
38     *  Constant: '<S1>/Constant'
39     */
40    Python_22_B.Compare = (Python_22_B.UARTRx > 0);
41
42    /* S-Function (stm32f4_digital_output): '<Root>/Digital Output' */
43
44    /* DigitalOutput */
45    {
46      *DigitalOutput_A5 = Python_22_B.Compare;
47    }
48  }
49
50  /* Model initialize function */
51  void Python_22_initialize(void)
52  {
53    /* Registration code */
54
55    /* initialize error status */
56    rtmSetErrorStatus(Python_22_M, (NULL));
57
58    /* block I/O */
59    (void) memset(((void *) &Python_22_B), 0,
60                  sizeof(B_Python_22_T));
61
62    /* Level2 S-Function Block: '<Root>/UART Rx' (stm32f4_usart) */
63    enable_UARTRx();
64
65    /* Level2 S-Function Block: '<Root>/Digital Output' 
(stm32f4_digital_output) */
66    enable_DigitalOutput();
67
68    /* Level2 S-Function Block: '<Root>/UART Setup' (stm32f4_usart) */
69    enable_UARTSetup();
70  }
71
72  /* Model terminate function */
73  void Python_22_terminate(void)
74  {
75    /* Terminate for S-Function (stm32f4_digital_output): 
'<Root>/Digital Output' */
76
77    /* terminate_DigitalOutput(); */
78  }
79
80  /* [EOF] */
Persönliche Seite #5843666
Lesenswert?

Dani schrieb:
> Kann es sein, dass (STM.write('0')) nicht 0 in matlab ist ? '0' ist in
> asci 0x30.

Ja, wie gesagt:

Niklas G. schrieb:
> '0' zu senden sieht nach dem ASCII-Zeichen 0 mit dem Wert 48
> aus; vergleichst du auf dem Controller mit einer echten 0?

Dani schrieb:
> Außerdem benutze ich keinen USB UART converter, weil der
> STM32F446re einen hat (ST-Link)

Auch da kannst du per Oszilloskop prüfen ob überhaupt etwas ankommt.

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren