Hi ;
This may be a very strange question but I need to ask this ;
While we start over coding on PBP , should we first write the "define" parameters and then set the "registers" such as port , tris , ansel etc .
I mean a code should be like exactly as below ? or the second one ?
Code:#config __CONFIG _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_OFF & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF __CONFIG _CONFIG2, _WRT_OFF & _PLLEN_OFF & _STVREN_OFF & _BORV_19 & _LVP_OFF #ENDCONFIG define OSC 4 OSCCON=%01101010 PORTA=%00010000 : TRISA=%00000000 PORTB=%00000000 : TRISB=%00001001 OPTION_REG=%11111111 ADCON0=%00000001 : ADCON1=%10110000 ANSELA=%00000 : ANSELB=%00001000 T1CON=%00110000 INTCON=%00000000 DEFINE LCD_DREG PORTA 'LCD data port DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4 DEFINE LCD_RSREG PORTA 'LCD register select port DEFINE LCD_RSBIT 6 'LCD register select bit DEFINE LCD_RWREG PORTB ' LCD read/write port DEFINE LCD_RWBIT 7 ' LCD read/write pin bit DEFINE LCD_EREG PORTA 'LCD enable port DEFINE LCD_EBIT 7 'LCD enable bit DEFINE LCD_BITS 4 'LCD bus size 4 or 8 DEFINE LCD_LINES 2 'Number lines on LCD DEFINE ADC_BITS 10 ' Set number of bits in result DEFINE ADC_SAMPLEUS 100 ' Set sampling time in uS DEFINE ADC_CLOCK 3
or just like this ?
Thanks ..Code:#config __CONFIG _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_OFF & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF __CONFIG _CONFIG2, _WRT_OFF & _PLLEN_OFF & _STVREN_OFF & _BORV_19 & _LVP_OFF #ENDCONFIG define OSC 4 DEFINE LCD_DREG PORTA 'LCD data port DEFINE LCD_DBIT 0 'LCD data starting bit 0 or 4 DEFINE LCD_RSREG PORTA 'LCD register select port DEFINE LCD_RSBIT 6 'LCD register select bit DEFINE LCD_RWREG PORTB ' LCD read/write port DEFINE LCD_RWBIT 7 ' LCD read/write pin bit DEFINE LCD_EREG PORTA 'LCD enable port DEFINE LCD_EBIT 7 'LCD enable bit DEFINE LCD_BITS 4 'LCD bus size 4 or 8 DEFINE LCD_LINES 2 'Number lines on LCD DEFINE ADC_BITS 10 ' Set number of bits in result DEFINE ADC_SAMPLEUS 100 ' Set sampling time in uS DEFINE ADC_CLOCK 3 OSCCON=%01101010 PORTA=%00010000 : TRISA=%00000000 PORTB=%00000000 : TRISB=%00001001 OPTION_REG=%11111111 ADCON0=%00000001 : ADCON1=%10110000 ANSELA=%00000 : ANSELB=%00001000 T1CON=%00110000 INTCON=%00000000




Bookmarks