Batterie okay sauf fréquence
This commit is contained in:
parent
d452faf402
commit
f4ede3f26e
3 changed files with 14 additions and 21 deletions
|
|
@ -5,9 +5,7 @@
|
|||
#include <USART.h>
|
||||
|
||||
float d;
|
||||
short v;
|
||||
int p;
|
||||
char test;
|
||||
|
||||
void MyBatterie_Init(void){
|
||||
MyGPIO_Init(GPIOC,4,In_Analog); // Init PORT pour recevoir tension
|
||||
|
|
@ -15,26 +13,20 @@ void MyBatterie_Init(void){
|
|||
MyADC_Init(ADC1,14); // Init ADC channel 14 pour convertir valeur
|
||||
MyADC_ActiveIT(ADC1,15,&handler_ADC); // Init interruption quand conversion finie
|
||||
|
||||
My_USART_Init(USART2); // Init USART pour envoyer batterie
|
||||
|
||||
My_USART_Init(USART1);
|
||||
MyUSART_ActiveIT(USART1,10,&handler);
|
||||
My_USART_Init(USART1); // Init USART pour envoyer batterie
|
||||
|
||||
start_conversion(ADC1); // Premiere conversion
|
||||
}
|
||||
|
||||
void handler_ADC (void){
|
||||
d = 1044;//ADC1->DR &~ (0xF << 12); // Retourne valeur numérique
|
||||
d = ADC1->DR &~ (0xF << 12); // Retourne valeur numérique
|
||||
d = d*3.3/4096;
|
||||
d = d*13*100/12;
|
||||
if ((p%10 > (int)d%10+2) || (p%10 < (int)d%10-2)){
|
||||
p = (int) d;
|
||||
send_USART(USART2,(p/10) + '0'); // Envoie le chiffre des dizaines
|
||||
send_USART(USART2,(p%10) + '0'); // Envoie le chiffre des unités
|
||||
send_USART(USART2,'%');
|
||||
//start_conversion(ADC1); // Recommence la conversion pour le prochain
|
||||
send_USART(USART1,(p/10) + '0'); // Envoie le chiffre des dizaines
|
||||
send_USART(USART1,(p%10) + '0'); // Envoie le chiffre des unités
|
||||
send_USART(USART1,'%');
|
||||
}
|
||||
|
||||
void handler(void){
|
||||
test = USART1->DR;
|
||||
test = test + 1;
|
||||
start_conversion(ADC1); // Recommence la conversion pour le prochain
|
||||
}
|
||||
|
|
@ -3,6 +3,5 @@
|
|||
|
||||
void MyBatterie_Init(void);
|
||||
void handler_ADC(void);
|
||||
void handler(void);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
Driver SPI normalement bon, roulis a tester
|
||||
|
||||
Port map carte nucléo :
|
||||
|
||||
Plateau :
|
||||
|
|
@ -23,4 +21,8 @@ prio interruption timer2 : 0
|
|||
Batterie :
|
||||
|
||||
?PC4 : Floating input (ADC12 CHANNEL14)
|
||||
!PA2 : Alternate output push pull (UART2 TX)
|
||||
!PA9 : Alternate output push pull (UART1 TX)
|
||||
prio interruption ADC : 15
|
||||
|
||||
Fonctionnement de la batterie okay, il faut voir quand est-ce qu'on recommence la conversion ou quand est-ce qu'on envoie la batterie.
|
||||
Il faudrait vérifier le driver SPI qui ne fonctionne pas.
|
||||
Loading…
Reference in a new issue