forked from acco/chti23
partie PWM
This commit is contained in:
parent
6d36e9c037
commit
1aea46f820
4 changed files with 60 additions and 45 deletions
16
elec/spice/pwm/PWM.net
Normal file
16
elec/spice/pwm/PWM.net
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
* U:\3MIC\s2\BE-CHTI\assembleur\chti23\elec\spice\pwm\PWM.asc
|
||||||
|
V1 Compteur 0 PULSE(0 3.3 0 5u 0 0 5u)
|
||||||
|
C1 Filtre 0 10n
|
||||||
|
R1 Filtre PWM 3.9k
|
||||||
|
V2 CompValue 0 SINE(1.65 1 2k)
|
||||||
|
B1 PWM 0 V=if(V(CompValue)>V(Compteur),3.3,0)
|
||||||
|
;ac dec 100 1 10meg
|
||||||
|
.tran 0 1.5m 0 0.01u
|
||||||
|
* Compteur de l'unité Timer
|
||||||
|
* Partie PWM de l'unité Timer
|
||||||
|
* TIMER3
|
||||||
|
* PB0
|
||||||
|
* Chanel 3
|
||||||
|
* STM32F103
|
||||||
|
.backanno
|
||||||
|
.end
|
|
@ -28,42 +28,26 @@ SortieSon dcw 0
|
||||||
|
|
||||||
CallbackSon proc
|
CallbackSon proc
|
||||||
;; 1. Il faut pouvoir utiliser SortieSon comme index d'iteration dans le tableau bruitverre
|
;; 1. Il faut pouvoir utiliser SortieSon comme index d'iteration dans le tableau bruitverre
|
||||||
push {r4,r5,r6,r7}
|
push {r4,r5,r6}
|
||||||
ldr r7,=SortieSon
|
ldr r1,=SortieSon ;sortie
|
||||||
ldr r1,=LongueurSon
|
ldr r2,=LongueurSon ;nb de sons
|
||||||
ldr r2,=Son
|
ldr r3,=Son ;adresse du tableau de sons
|
||||||
mov r3,#0
|
mov r4,#0 ;compteur
|
||||||
mov r4,#719
|
mov r5,#(1<<15) ;registre pour operations
|
||||||
lsr r4,r4,#1
|
mov r6,#719 ;sauvegarde de 719
|
||||||
|
|
||||||
calcul
|
calcul
|
||||||
ldrsh r0, [r2,r3,lsl #1]
|
ldrsh r0, [r3,r4,lsl #1]
|
||||||
;cmp r0,#0x00007FFF
|
;faire +32768, ensuite x719, puis diviser par 2^16
|
||||||
;bgt calcul_neg
|
add r0,r5
|
||||||
;faire +32768, ensuite x719, puis diviser par 2^16
|
mul r0,r0,r6
|
||||||
mov r5,#32767
|
lsr r0,#16
|
||||||
udiv r6,r5,r4
|
str r0,[r1]
|
||||||
mul r0,r6
|
add r4,#1
|
||||||
add r0,r4
|
cmp r2,r4
|
||||||
str r0,[r7]
|
|
||||||
add r3,#1
|
|
||||||
cmp r1,r3
|
|
||||||
bne calcul
|
|
||||||
bl fin
|
|
||||||
|
|
||||||
calcul_neg
|
|
||||||
mov r5,#32768
|
|
||||||
udiv r6,r4,r5
|
|
||||||
mul r0,r6
|
|
||||||
sub r0,r4
|
|
||||||
lsl r5,r0,#1
|
|
||||||
sub r0,r5
|
|
||||||
str r0,[r7]
|
|
||||||
add r3,#1
|
|
||||||
cmp r1,r3
|
|
||||||
bne calcul
|
bne calcul
|
||||||
|
|
||||||
fin
|
pop {r4,r5,r6}
|
||||||
pop {r4,r5,r6,r7}
|
endp
|
||||||
|
|
||||||
END
|
END
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include "DriverJeuLaser.h"
|
#include "DriverJeuLaser.h"
|
||||||
|
//#include "../Driver/DriverJeuLaser.inc"
|
||||||
extern void CallbackSon(void);
|
extern void CallbackSon(void);
|
||||||
extern int PeriodeSonMicroSec;
|
extern int PeriodeSonMicroSec;
|
||||||
|
|
||||||
|
@ -17,9 +18,12 @@ CLOCK_Configure();
|
||||||
|
|
||||||
Timer_1234_Init_ff(TIM4, (1/PeriodeSonMicroSec*0.000001) );
|
Timer_1234_Init_ff(TIM4, (1/PeriodeSonMicroSec*0.000001) );
|
||||||
Active_IT_Debordement_Timer( TIM4, 2, CallbackSon );
|
Active_IT_Debordement_Timer( TIM4, 2, CallbackSon );
|
||||||
|
|
||||||
|
//Timer_1234_Init_ff(TIM3, 720 );
|
||||||
|
char GPIO_Configure(GPIOB, 0, OUTPUT, ALT_PPULL);
|
||||||
|
PWM_Init_ff(TIM3,3,720);
|
||||||
|
PWM_Set_Value_TIM3_Ch3(720);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
|
|
|
@ -157,9 +157,9 @@
|
||||||
<Bp>
|
<Bp>
|
||||||
<Number>0</Number>
|
<Number>0</Number>
|
||||||
<Type>0</Type>
|
<Type>0</Type>
|
||||||
<LineNumber>37</LineNumber>
|
<LineNumber>42</LineNumber>
|
||||||
<EnabledFlag>1</EnabledFlag>
|
<EnabledFlag>1</EnabledFlag>
|
||||||
<Address>134220580</Address>
|
<Address>134220588</Address>
|
||||||
<ByteObject>0</ByteObject>
|
<ByteObject>0</ByteObject>
|
||||||
<HtxType>0</HtxType>
|
<HtxType>0</HtxType>
|
||||||
<ManyObjects>0</ManyObjects>
|
<ManyObjects>0</ManyObjects>
|
||||||
|
@ -168,7 +168,23 @@
|
||||||
<BreakIfRCount>1</BreakIfRCount>
|
<BreakIfRCount>1</BreakIfRCount>
|
||||||
<Filename>.\Src\GestionSon.s</Filename>
|
<Filename>.\Src\GestionSon.s</Filename>
|
||||||
<ExecCommand></ExecCommand>
|
<ExecCommand></ExecCommand>
|
||||||
<Expression>\\StepSon\Src/GestionSon.s\37</Expression>
|
<Expression>\\StepSon\Src/GestionSon.s\42</Expression>
|
||||||
|
</Bp>
|
||||||
|
<Bp>
|
||||||
|
<Number>1</Number>
|
||||||
|
<Type>0</Type>
|
||||||
|
<LineNumber>38</LineNumber>
|
||||||
|
<EnabledFlag>1</EnabledFlag>
|
||||||
|
<Address>0</Address>
|
||||||
|
<ByteObject>0</ByteObject>
|
||||||
|
<HtxType>0</HtxType>
|
||||||
|
<ManyObjects>0</ManyObjects>
|
||||||
|
<SizeOfObject>0</SizeOfObject>
|
||||||
|
<BreakByAccess>0</BreakByAccess>
|
||||||
|
<BreakIfRCount>0</BreakIfRCount>
|
||||||
|
<Filename>.\Src\GestionSon.s</Filename>
|
||||||
|
<ExecCommand></ExecCommand>
|
||||||
|
<Expression></Expression>
|
||||||
</Bp>
|
</Bp>
|
||||||
</Breakpoint>
|
</Breakpoint>
|
||||||
<WatchWindow1>
|
<WatchWindow1>
|
||||||
|
@ -187,17 +203,12 @@
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>r0</ItemText>
|
<ItemText>r0</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
<Ww>
|
|
||||||
<count>3</count>
|
|
||||||
<WinNumber>1</WinNumber>
|
|
||||||
<ItemText>r7</ItemText>
|
|
||||||
</Ww>
|
|
||||||
</WatchWindow1>
|
</WatchWindow1>
|
||||||
<MemoryWindow1>
|
<MemoryWindow1>
|
||||||
<Mm>
|
<Mm>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<SubType>0</SubType>
|
<SubType>0</SubType>
|
||||||
<ItemText>r7</ItemText>
|
<ItemText>r3</ItemText>
|
||||||
<AccSizeX>0</AccSizeX>
|
<AccSizeX>0</AccSizeX>
|
||||||
</Mm>
|
</Mm>
|
||||||
</MemoryWindow1>
|
</MemoryWindow1>
|
||||||
|
@ -271,7 +282,7 @@
|
||||||
<Wi>
|
<Wi>
|
||||||
<IntNumber>0</IntNumber>
|
<IntNumber>0</IntNumber>
|
||||||
<FirstString>`SortieSon</FirstString>
|
<FirstString>`SortieSon</FirstString>
|
||||||
<SecondString>FF0000000000000000000000000000000080864000000000000000000000000000000000536F72746965536F6E00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000700000001000000000000000000F03F1000000000000000000000000000000000000000C40A0008</SecondString>
|
<SecondString>FF0000000000000000000000000000000078864000000000000000000000000000000000536F72746965536F6E00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000700000001000000000000000000F03F1000000000000000000000000000000000000000C40A0008</SecondString>
|
||||||
</Wi>
|
</Wi>
|
||||||
</LogicAnalyzers>
|
</LogicAnalyzers>
|
||||||
<DebugDescription>
|
<DebugDescription>
|
||||||
|
|
Loading…
Reference in a new issue