Z
Zanor
Guest
Salut!
J'utilise ADC sur 16f819 et peu taper le résultat à mon PC.Mais le résultat ADC est si instable, il garde sautant sur place (ex. 950 sauts entre 947 et 953).
J'ai connecté un pot 1k aux entrées.
voici mon code mikroC:
Code:
unsigned données à court = 0, ro = 1;
unsigned short * ER;void Comm_WriteConst (const char * s)
(
while (* s)
(
Soft_Uart_Write (* s);
s ;
)
)SENDB void (char sendme) (
Soft_UART_Write (sendme);
)void WAITB () (
while (* er) (
= données Soft_UART_Read (er);
)
ro = 1;
)void main () (
er = &ro;OSCCON = 0xFF;
TRISA = 0xFF;
TRISB = 0b00000010;
PORTA = 0b00000000;
PORTB = 0b00000000;ADCON0 = 0b01000001; / / Nombre de 20MHz, le canal 0, ADC ON
ADCON1 = 0b01000000; / / 4 canaux analogiques et
/ / Justification à gauche (ADRESH = 8bit résultat)Soft_UART_Init (PORTB, 1, 0, 9600, 0);
Delay_ms (10);while (1) (WAITB ();if (data == 'a')
(
SENDB ( 'a');ADCON0 = 0b01000001;
Delay_ms (1);
ADCON0 = 0b01000101;
while (ADCON0 & 0x4);
SENDB (ADRESH);
SENDB (ADRESL);ADCON0 = 0b01001001;
Delay_ms (1);
ADCON0 = 0b01001101;
while (ADCON0 & 0x4);
SENDB (ADRESH);
)))
J'utilise ADC sur 16f819 et peu taper le résultat à mon PC.Mais le résultat ADC est si instable, il garde sautant sur place (ex. 950 sauts entre 947 et 953).
J'ai connecté un pot 1k aux entrées.
voici mon code mikroC:
Code:
unsigned données à court = 0, ro = 1;
unsigned short * ER;void Comm_WriteConst (const char * s)
(
while (* s)
(
Soft_Uart_Write (* s);
s ;
)
)SENDB void (char sendme) (
Soft_UART_Write (sendme);
)void WAITB () (
while (* er) (
= données Soft_UART_Read (er);
)
ro = 1;
)void main () (
er = &ro;OSCCON = 0xFF;
TRISA = 0xFF;
TRISB = 0b00000010;
PORTA = 0b00000000;
PORTB = 0b00000000;ADCON0 = 0b01000001; / / Nombre de 20MHz, le canal 0, ADC ON
ADCON1 = 0b01000000; / / 4 canaux analogiques et
/ / Justification à gauche (ADRESH = 8bit résultat)Soft_UART_Init (PORTB, 1, 0, 9600, 0);
Delay_ms (10);while (1) (WAITB ();if (data == 'a')
(
SENDB ( 'a');ADCON0 = 0b01000001;
Delay_ms (1);
ADCON0 = 0b01000101;
while (ADCON0 & 0x4);
SENDB (ADRESH);
SENDB (ADRESL);ADCON0 = 0b01001001;
Delay_ms (1);
ADCON0 = 0b01001101;
while (ADCON0 & 0x4);
SENDB (ADRESH);
)))