PWM_Fonctionnel
This commit is contained in:
parent
f17dd1744f
commit
ab7278d21a
3 changed files with 33 additions and 31 deletions
|
@ -34,29 +34,33 @@ void MyPWM_init ( TIM_TypeDef * Timer,char Channel)
|
||||||
if(Channel==1)
|
if(Channel==1)
|
||||||
{
|
{
|
||||||
Timer->CCMR1&=~0x00FF;
|
Timer->CCMR1&=~0x00FF;
|
||||||
Timer->CCMR1|=0x11<<5;
|
Timer->CCMR1 &= ~TIM_CCMR1_OC1M_0;
|
||||||
Timer->CCMR1&=~0x000F;
|
Timer->CCMR1 |= TIM_CCMR1_OC1M_1| TIM_CCMR1_OC1M_2;
|
||||||
|
Timer->CCER |= TIM_CCER_CC1E;
|
||||||
|
|
||||||
}
|
}
|
||||||
if(Channel==2)
|
if(Channel==2)
|
||||||
{
|
{
|
||||||
Timer->CCMR1&=~0xFF00;
|
Timer->CCMR1&=~0xFF00;
|
||||||
Timer->CCMR1|=0x11<<12;
|
Timer->CCMR1 &= ~TIM_CCMR1_OC2M_0;
|
||||||
Timer->CCMR1&=~0x0F00;
|
Timer->CCMR1 |= TIM_CCMR1_OC2M_1| TIM_CCMR1_OC2M_2;
|
||||||
|
Timer->CCER |= TIM_CCER_CC2E;
|
||||||
|
|
||||||
}
|
}
|
||||||
if(Channel==3)
|
if(Channel==3)
|
||||||
{
|
{
|
||||||
Timer->CCMR2&=~0x00FF;
|
Timer->CCMR2&=~0x00FF;
|
||||||
Timer->CCMR2|=0x11<<5;
|
Timer->CCMR2 &= ~TIM_CCMR2_OC3M_0;
|
||||||
Timer->CCMR2&=~0x000F;
|
Timer->CCMR2 |= TIM_CCMR2_OC3M_1| TIM_CCMR2_OC3M_2;
|
||||||
|
Timer->CCER |= TIM_CCER_CC3E;
|
||||||
|
|
||||||
}
|
}
|
||||||
if(Channel==4)
|
if(Channel==4)
|
||||||
{
|
{
|
||||||
Timer->CCMR2&=~0xFF00;
|
Timer->CCMR2&=~0xFF00;
|
||||||
Timer->CCMR2|=0x11<<12;
|
Timer->CCMR2 &= ~TIM_CCMR2_OC4M_0;
|
||||||
Timer->CCMR2&=~0x0F00;
|
Timer->CCMR2 |= TIM_CCMR2_OC4M_1| TIM_CCMR2_OC4M_2;
|
||||||
|
Timer->CCER |= TIM_CCER_CC4E;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,11 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Mafonction_IT (void);
|
void MyFunction_IT (void);
|
||||||
MyGPIO_Struct_TypeDef PA5;
|
MyGPIO_Struct_TypeDef PA5;
|
||||||
|
MyGPIO_Struct_TypeDef PA6;
|
||||||
MyGPIO_Struct_TypeDef PC13;
|
MyGPIO_Struct_TypeDef PC13;
|
||||||
MyTimer_Struct_TypeDef timer2;
|
MyTimer_Struct_TypeDef timer3;
|
||||||
//PA5 LED
|
//PA5 LED
|
||||||
//PC13 Bouton
|
//PC13 Bouton
|
||||||
|
|
||||||
|
@ -17,25 +18,32 @@ int main ( void )
|
||||||
PA5.GPIO_Conf=Out_Ppull;
|
PA5.GPIO_Conf=Out_Ppull;
|
||||||
PA5.GPIO_Pin=5;
|
PA5.GPIO_Pin=5;
|
||||||
MyGPIO_Init(&PA5);
|
MyGPIO_Init(&PA5);
|
||||||
timer2.Timer=TIM2;
|
PA6.GPIO=GPIOA;
|
||||||
timer2.ARR=35999; //pour avoir 500ms
|
PA6.GPIO_Conf=AltOut_Ppull;
|
||||||
timer2.PSC=1000;
|
PA6.GPIO_Pin=6;
|
||||||
MyTimer_Base_Init(&timer2);
|
MyGPIO_Init(&PA6);
|
||||||
MyTimer_ActiveIT(timer2.Timer,1, &Mafonction_IT);
|
|
||||||
MyTimer_Base_Start(timer2.Timer);
|
timer3.Timer=TIM3;
|
||||||
MyPWM_init (TIM2,1);
|
timer3.ARR=35999; //pour avoir 500ms
|
||||||
MyPWM_Duty (TIM2,1, 10000);
|
timer3.PSC=1000;
|
||||||
|
MyTimer_Base_Init(&timer3);
|
||||||
|
MyTimer_ActiveIT(timer3.Timer,1, &MyFunction_IT);
|
||||||
|
MyTimer_Base_Start(timer3.Timer);
|
||||||
|
|
||||||
|
MyPWM_init (TIM3,1);
|
||||||
|
MyPWM_Duty (TIM3,1, 10000);
|
||||||
|
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Mafonction_IT (void)
|
void MyFunction_IT (void)
|
||||||
{
|
{
|
||||||
MyGPIO_Toggle(PA5.GPIO,5);
|
MyGPIO_Toggle(PA5.GPIO,5);
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@
|
||||||
<SetRegEntry>
|
<SetRegEntry>
|
||||||
<Number>0</Number>
|
<Number>0</Number>
|
||||||
<Key>DLGDARM</Key>
|
<Key>DLGDARM</Key>
|
||||||
<Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=733,260,1154,687,0)(121=-1,-1,-1,-1,0)(122=1345,565,1766,992,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=-1,-1,-1,-1,0)(131=1189,292,1783,1043,1)(132=-1,-1,-1,-1,0)(133=-1,-1,-1,-1,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(234=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0)</Name>
|
<Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=873,10,1294,437,1)(121=-1,-1,-1,-1,0)(122=1345,565,1766,992,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=-1,-1,-1,-1,0)(131=862,435,1456,1186,0)(132=870,423,1464,1174,1)(133=-1,-1,-1,-1,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(234=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0)</Name>
|
||||||
</SetRegEntry>
|
</SetRegEntry>
|
||||||
<SetRegEntry>
|
<SetRegEntry>
|
||||||
<Number>0</Number>
|
<Number>0</Number>
|
||||||
|
@ -159,7 +159,7 @@
|
||||||
<AscS3>0</AscS3>
|
<AscS3>0</AscS3>
|
||||||
<aSer3>0</aSer3>
|
<aSer3>0</aSer3>
|
||||||
<eProf>0</eProf>
|
<eProf>0</eProf>
|
||||||
<aLa>1</aLa>
|
<aLa>0</aLa>
|
||||||
<aPa1>0</aPa1>
|
<aPa1>0</aPa1>
|
||||||
<AscS4>0</AscS4>
|
<AscS4>0</AscS4>
|
||||||
<aSer4>0</aSer4>
|
<aSer4>0</aSer4>
|
||||||
|
@ -188,16 +188,6 @@
|
||||||
<SecondString>FF000000000000000000000000000000E0FFEF400100000000000000000000000000000028504F5254412026203078303030303030323029203E3E2035000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000F03F170000000000000000000000000000000000000090020008</SecondString>
|
<SecondString>FF000000000000000000000000000000E0FFEF400100000000000000000000000000000028504F5254412026203078303030303030323029203E3E2035000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000F03F170000000000000000000000000000000000000090020008</SecondString>
|
||||||
</Wi>
|
</Wi>
|
||||||
</LogicAnalyzers>
|
</LogicAnalyzers>
|
||||||
<SystemViewers>
|
|
||||||
<Entry>
|
|
||||||
<Name>System Viewer\ADC1</Name>
|
|
||||||
<WinId>35905</WinId>
|
|
||||||
</Entry>
|
|
||||||
<Entry>
|
|
||||||
<Name>System Viewer\TIM2</Name>
|
|
||||||
<WinId>35904</WinId>
|
|
||||||
</Entry>
|
|
||||||
</SystemViewers>
|
|
||||||
<DebugDescription>
|
<DebugDescription>
|
||||||
<Enable>1</Enable>
|
<Enable>1</Enable>
|
||||||
<EnableFlashSeq>1</EnableFlashSeq>
|
<EnableFlashSeq>1</EnableFlashSeq>
|
||||||
|
|
Loading…
Reference in a new issue