Jump to content

walshy

Members
  • Content Count

    1
  • Joined

  • Last visited

Everything posted by walshy

  1. hi all trying to use th ADC on the pic16F876A a little confused as to how to use the ADC functionality with source boost anyone with any help on this #include <system.h> #define OP_PORT_0 porta.4 #define OP_PORT_1 porta.5 #define IP_PORT_ porta.1 #define TX_PORT 0x07 #define TX_TRIS 0x87 #define TX_BIT 6 #define RX_PORT 0x07 #define RX_TRIS 0x87 #define RX_BIT 7 #define e_SPBRG 0x99 #define e_RCREG 0x1a #define e_TXREG 0x019 #define e_TXSTA 0x98 #define e_RCSTA 0x18 #define e_TXIF_PIR 0x0c #define e_RCIF_PIR 0x0c #define e_TXIF_BIT 4 #define e_RCIF_BIT 5 #define MODE (USART_reset_wdt | USART_HW) #define bit_time 260 #include <rs232_driver.h> void main() { // Set porta as digital output port set_bit ( adcon1, ADFM ); set_bit( adcon1, PCFG0 ); clear_bit ( adcon1, PCFG1 ); set_bit ( adcon1, PCFG2 ); set_bit( adcon1, PCFG3 ); // Set up interrupt control set_bit( intcon, T0IE ); set_bit( intcon, GIE ); // Config timer in option reg clear_bit( option_reg, T0CS ); clear_bit( option_reg, T0SE ); // Config timer pre-scalar assignments set_bit ( option_reg, PSA ); clear_bit( option_reg, PS2 ); clear_bit( option_reg, PS1 ); clear_bit( option_reg, PS0 ); // Set timer1 clear_bit( t1con, T1CKPS1 ); clear_bit( t1con, T1CKPS0 ); set_bit ( t1con, TMR1ON ); trisa = 14; porta = 0; // BAUD RATE: 9600 uart_init( 1, (20000000/(16*9600)) ); while(1) { if ( getc() ) { char adc_val = //ADC? } } }
×
×
  • Create New...