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
|
||||
;; 1. Il faut pouvoir utiliser SortieSon comme index d'iteration dans le tableau bruitverre
|
||||
push {r4,r5,r6,r7}
|
||||
ldr r7,=SortieSon
|
||||
ldr r1,=LongueurSon
|
||||
ldr r2,=Son
|
||||
mov r3,#0
|
||||
mov r4,#719
|
||||
lsr r4,r4,#1
|
||||
push {r4,r5,r6}
|
||||
ldr r1,=SortieSon ;sortie
|
||||
ldr r2,=LongueurSon ;nb de sons
|
||||
ldr r3,=Son ;adresse du tableau de sons
|
||||
mov r4,#0 ;compteur
|
||||
mov r5,#(1<<15) ;registre pour operations
|
||||
mov r6,#719 ;sauvegarde de 719
|
||||
|
||||
calcul
|
||||
ldrsh r0, [r2,r3,lsl #1]
|
||||
;cmp r0,#0x00007FFF
|
||||
;bgt calcul_neg
|
||||
ldrsh r0, [r3,r4,lsl #1]
|
||||
;faire +32768, ensuite x719, puis diviser par 2^16
|
||||
mov r5,#32767
|
||||
udiv r6,r5,r4
|
||||
mul r0,r6
|
||||
add r0,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
|
||||
add r0,r5
|
||||
mul r0,r0,r6
|
||||
lsr r0,#16
|
||||
str r0,[r1]
|
||||
add r4,#1
|
||||
cmp r2,r4
|
||||
bne calcul
|
||||
|
||||
fin
|
||||
pop {r4,r5,r6,r7}
|
||||
pop {r4,r5,r6}
|
||||
endp
|
||||
|
||||
END
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
|
||||
#include "DriverJeuLaser.h"
|
||||
//#include "../Driver/DriverJeuLaser.inc"
|
||||
extern void CallbackSon(void);
|
||||
extern int PeriodeSonMicroSec;
|
||||
|
||||
|
@ -18,7 +19,10 @@ CLOCK_Configure();
|
|||
Timer_1234_Init_ff(TIM4, (1/PeriodeSonMicroSec*0.000001) );
|
||||
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>
|
||||
<Number>0</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>37</LineNumber>
|
||||
<LineNumber>42</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>134220580</Address>
|
||||
<Address>134220588</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
|
@ -168,7 +168,23 @@
|
|||
<BreakIfRCount>1</BreakIfRCount>
|
||||
<Filename>.\Src\GestionSon.s</Filename>
|
||||
<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>
|
||||
</Breakpoint>
|
||||
<WatchWindow1>
|
||||
|
@ -187,17 +203,12 @@
|
|||
<WinNumber>1</WinNumber>
|
||||
<ItemText>r0</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>3</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>r7</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<MemoryWindow1>
|
||||
<Mm>
|
||||
<WinNumber>1</WinNumber>
|
||||
<SubType>0</SubType>
|
||||
<ItemText>r7</ItemText>
|
||||
<ItemText>r3</ItemText>
|
||||
<AccSizeX>0</AccSizeX>
|
||||
</Mm>
|
||||
</MemoryWindow1>
|
||||
|
@ -271,7 +282,7 @@
|
|||
<Wi>
|
||||
<IntNumber>0</IntNumber>
|
||||
<FirstString>`SortieSon</FirstString>
|
||||
<SecondString>FF0000000000000000000000000000000080864000000000000000000000000000000000536F72746965536F6E00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000700000001000000000000000000F03F1000000000000000000000000000000000000000C40A0008</SecondString>
|
||||
<SecondString>FF0000000000000000000000000000000078864000000000000000000000000000000000536F72746965536F6E00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000700000001000000000000000000F03F1000000000000000000000000000000000000000C40A0008</SecondString>
|
||||
</Wi>
|
||||
</LogicAnalyzers>
|
||||
<DebugDescription>
|
||||
|
|
Loading…
Reference in a new issue