Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

LCD Interface with dsPIC30F

Status
Not open for further replies.

Suj

Newbie level 3
Joined
Apr 30, 2010
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
India
Activity points
1,304
Can some one please help for the 16 x2 bit LCD interface with dspic30f?
 

Connect vcc, vss & a resistor or VR on appropriate pins and also data (8bit or 4bit).

But why you selected dsPIC30 for your application. Bcoz I don't think you are going to do any signal processing :D:D
 

yes i am doing signal processing..
 

Please help for dspic30f ADC code for simultaneous sampling...
 

Hi,
I haven't used the dsPIC30, but I have used dsPIC33 and here's the code for simultaneous sampling:
Code:
#include <p33fj16gp304.h>

_FBS(0xFFFF);
_FGS(0x0007);
_FOSCSEL(0x0003);
_FOSC(0x00E1);
_FWDT(0x0000);
_FPOR(0x00F0);
_FICD(0x00C1);

void delay (void)
{	T3CONbits.TON = 1;
	while (!_T3IF);
}// end sub

void main (void)
{	TRISAbits.TRISA0 = 1;
	TRISAbits.TRISA1 = 1;
	TRISCbits.TRISC0 = 1;
	TRISB = 0;
	T3CON = 0x8030;
	PR3 = 12500;
//ADC Configuration:
	AD1CON1bits.AD12B = 0; //10-bit
	AD1CON2bits.CHPS = 1; //CH0 and CH1
	AD1CON2bits.VCFG = 0; //AVDD-AVSS
	AD1CON3bits.ADCS = 2; //ADCS = 2, TAD = 75n	
	AD1CON1bits.FORM1 =	 0; //integer
	AD1CON1bits.SSRC = 7; //auto convert
	AD1PCFGL = 0xFFFC; //CH0, CH1
	AD1CON1bits.SIMSAM = 1; //Simultaneous scanning
	AD1CON2bits.ALTS = 0; //Dont' alternate between MuxA and MuxB
	AD1CHS0bits.CH0NA = 0; //AVss
	AD1CHS0bits.CH0NB = 0; //AVss
	AD1CHS0bits.CH0SA = 6; //For Ch0, MuxA, AN6
	AD1CHS123bits.CH123NA = 0; //VREF-
	AD1CHS123bits.CH123NB = 0; //VREF-
	AD1CON1bits.ADON = 1; //Start ADC Module
//done with ADC config
	while (1)
	{	AD1CON1bits.SAMP = 1;
		while (!AD1CON1bits.DONE);
		LATB = ADC1BUF0 >> 2;
		delay;
		LATB = ADC1BUF1 >> 2;
		delay;
	}//wend
}//end.

After a little programming in C30, I moved to mikroBASIC. So here's a code for multi-sampling in PIC24. I've heard the modules in PIC24 and dsPIC30 are similar. So here's the code:
Code:
program multisampleADC

dim ADCValue as word

main:

     AD1PCFG = $0000 ' All channels are Analog
     AD1CSSL = $FFFF ' Scan all channels
     AD1CHS  = $0000 ' Start with AN0 (dont matter coz o' samplin)
     AD1CON1 = $00E0
     '====================================================================='
     ' bit 15:    ADON = 0; ADC Module off to allow write to all other registers; recommended in datasheet
     ' bit 14:    Unimplemented
     ' bit 13:    ADSIDL = 0; Stop in idle mode
     ' bit 12:    Unimplemented
     ' bit 11:    Unimplemented
     ' bit 10:    Unimplemented
     ' bit 9:     Form1 = 0; For decimal value
     ' bit 8:     Form0 = 0; For decimal value
     ' bit 7:     SSRC2 = 1; For autoconvert
     ' bit 6:     SSRC1 = 1; For autoconvert
     ' bit 5:     SSRC0 = 1; For autoconvert
     ' bit 4:     Unimplemented
     ' bit 3:     Unimplemented
     ' bit 2:     ASAM = 0; Autosample off
     ' bit 1:     SAMP = 0;
     ' bit 0:     DONE = 0;
     '====================================================================='
     AD1CON2 = $043C
     '====================================================================='
     ' bit 15:    VCFG2 = 0; For Vr+ = Vdd, Vr- = Vss
     ' bit 14:    VCFG1 = 0; For Vr+ = Vdd, Vr- = Vss
     ' bit 13:    VCFG0 = 0; For Vr+ = Vdd, Vr- = Vss
     ' bit 12:    Reserved
     ' bit 11:    Unimplemented
     ' bit 10:    CSCNA = 1; Scan inputs
     ' bit 9:     Unimplemented
     ' bit 8:     Unimplemented
     ' bit 7:     BUFS = 0
     ' bit 6:     Unimplemented
     ' bit 5:     SMPI3 = 1; Interrupt after conversion of all channels (16th sample)
     ' bit 4:     SMPI2 = 1; Interrupt after conversion of all channels (16th sample)
     ' bit 3:     SMPI1 = 1; Interrupt after conversion of all channels (16th sample)
     ' bit 2:     SMPI0 = 1; Interrupt after conversion of all channels (16th sample)
     ' bit 1:     BUFM = 0; Buffer configured as 16bit register
     ' bit 0:     ALTS = 0; Always use MUXA
     '====================================================================='
     AD1CON3 = $0C02
     '====================================================================='
     ' bit 15:    ADRC = 0; Clock derived from System Clock
     ' bit 14:    Unimplemented
     ' bit 13:    Unimplemented
     ' bit 12:    SAMC4 = 0; Set for 12Tad
     ' bit 11:    SAMC3 = 1; Set for 12Tad
     ' bit 10:    SAMC2 = 1; Set for 12Tad
     ' bit 9:     SAMC1 = 0; Set for 12Tad
     ' bit 8:     SAMC0 = 0; Set for 12Tad
     ' bit 7:     ADCS7 = 0; Set for 2Tcy
     ' bit 6:     ADCS6 = 0; Set for 2Tcy
     ' bit 5:     ADCS5 = 0; Set for 2Tcy
     ' bit 4:     ADCS4 = 0; Set for 2Tcy
     ' bit 3:     ADCS3 = 0; Set for 2Tcy
     ' bit 2:     ADCS2 = 0; Set for 2Tcy
     ' bit 1:     ADCS1 = 0; Set for 2Tcy
     ' bit 0:     ADCS0 = 1; Set for 2Tcy
     '====================================================================='
     TRISA   = $FF00
     TRISB   = $FFFF
     TRISD   = $0000
     AD1CON1.15 = 1 'Start ADC [AD1CON1.15 = AD1CON1.ADON]
     
     while TRUE
           AD1CON1.1 = 1 'Start Sampling
           
           while (AD1CON1.0 = 0)
                 if (AD1CON1.1 = 0) then
                    AD1CON1.2 = 1 'Sampling has started and first sampling is done so start autosampling
                 end if
           wend
           
           ADCValue = ADC1BUF0 >> 2
           PORTA = ADCVALUE
           delay_ms(500)
           LATA = 0
           LATD = 0
           LATD.0 = 1
           
           ADCValue = ADC1BUF1 >> 2
           PORTA = ADCVALUE
           delay_ms(500)
           LATA = 0
           PORTD = 1
           LATD.1 = 1

           ADCValue = ADC1BUF2 >> 2
           PORTA = ADCVALUE
           delay_ms(500)
           LATD = 0
           LATD.2 = 1
           
           ADCValue = ADC1BUF3 >> 2
           PORTA = ADCVALUE
           delay_ms(500)
           LATA = 0
           LATD = 0
           LATD.3 = 1
           
           ADCValue = ADC1BUF4 >> 2
           PORTA = ADCVALUE
           delay_ms(500)
           LATA = 0
           LATD = 0
           LATD.4 = 1
           
           ADCValue = ADC1BUF5 >> 2
           PORTA = ADCVALUE
           delay_ms(500)
           LATA = 0
           LATD = 0
           LATD.5 = 1
           
           ADCValue = ADC1BUF6 >> 2
           PORTA = ADCVALUE
           delay_ms(500)
           LATA = 0
           LATD = 0
           LATD.6 = 1
           
           ADCValue = ADC1BUF7 >> 2
           PORTA = ADCVALUE
           delay_ms(500)
           LATA = 0
           LATD = 0
           LATD.7 = 1
           
           ADCValue = ADC1BUF8 >> 2
           PORTA = ADCVALUE
           delay_ms(500)
           LATA = 0
           LATD = 0
           LATD.8 = 1
           
           ADCValue = ADC1BUF9 >> 2
           PORTA = ADCVALUE
           delay_ms(500)
           LATA = 0
           LATD = 0
           LATD.9 = 1
           
           ADCValue = ADC1BUFA >> 2
           PORTA = ADCVALUE
           delay_ms(500)
           LATA = 0
           LATD = 0
           LATD.10 = 1
           
           ADCValue = ADC1BUFB >> 2
           PORTA = ADCVALUE
           delay_ms(500)
           LATA = 0
           LATD = 0
           LATD.11 = 1
           
           ADCValue = ADC1BUFC >> 2
           PORTA = ADCVALUE
           delay_ms(500)
           LATA = 0
           LATD = 0
           LATD.12 = 1
           
           ADCValue = ADC1BUFD >> 2
           PORTA = ADCVALUE
           delay_ms(500)
           LATA = 0
           LATD = 0
           LATD.13 = 1
           
           ADCValue = ADC1BUFE >> 2
           PORTA = ADCVALUE
           delay_ms(500)
           LATD = 0
           LATD.14 = 1
           
           ADCValue = ADC1BUFF >> 2
           PORTA = ADCVALUE
           delay_ms(500)
           LATA = 0
           LATD = 0
           LATD.15 = 1
           
     wend

end.

Hope this helps.
Tahmid.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top