I desire right to put AN0 in analogical input with 18f4550

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
le_joebar
Posts: 1
Joined: Mon Jan 14, 2008 6:28 pm
Location: Bruxelles

I desire right to put AN0 in analogical input with 18f4550

Post by le_joebar » Wed Mar 12, 2008 6:01 pm

hello,
Here my problem I desire right to put AN0 in analogical input and I do not know how to make! here my code:


Device = 18F4550

Clock = 48

#option LCD_DATA = PORTD.4
#option LCD_RS = PORTE.0
#option LCD_EN = PORTE.1

// 20Mhz crystal, 48Mhz internal (FS USB)

Config

PLLDIV = 5,

CPUDIV = OSC1_PLL2,

USBDIV = 2,

FOSC =HSpll_hs,

VREGEN = On










// import modules...
Include "utils.bas"
Include "usbhid.bas"
Include "usart.bas"
Include "convert.bas"
Include "LCD.bas"


// TX report...

Structure TTXReport

Time As Word

Message As String





End Structure

Dim TXReport As TTXReport Absolute TXReportRAM

// RX report...





Structure TRXReport

LED7 As Bit
LED6 As Bit
LED5 As Bit
LED4 As Bit
LED3 As Bit
LED2 As Bit
LED1 As Bit
LED0 As Bit
car1 As Char
car2 As Char
car3 As Char
car4 As Char
car5 As Char
car6 As Char
car7 As Char
car8 As Char




End Structure








Dim RXReport As TRXReport Absolute RXReportRAM



// alias port pins to LEDs...

Dim

LED0 As PORTB.7,
LED1 As PORTB.6,
LED2 As PORTB.5,
LED3 As PORTB.4,
LED4 As PORTB.3,
LED5 As PORTB.2,
LED6 As PORTB.1,
LED7 As PORTB.0,
car1 As Char,
car2 As Char,
car3 As Char,
car4 As Char,
car5 As Char,
car6 As Char,
car7 As Char,
car8 As Char
// initialise...

TXReport.Time = 0

Low(LED0)
Low(LED1)
Low(LED2)
Low(LED3)
Low(LED4)
Low(LED5)
Low(LED6)
Low(LED7)
// connect to USB...

Repeat

Until Attached





// main program loop...
// SetAllDigital

TRISA = %11111111
TRISB = %00000000

// here adcon ????

SetBaudrate(br19200)
WriteAt(1,1,"Bonjour Joel")
DelayMS (2000)
Cls

While true




// if we have data, set port values, update message
// and then reset time counter...
If DataAvailable Then
ReadReport

LED0 = RXReport.LED0
LED1 = RXReport.LED1
LED2 = RXReport.LED2
LED3 = RXReport.LED3
LED4 = RXReport.LED4
LED5 = RXReport.LED5
LED6 = RXReport.LED6
LED7 = RXReport.LED7
car1 = RXReport.car1
car2 = RXReport.car2
car3 = RXReport.car3
car4 = RXReport.car4
car5 = RXReport.car5
car6 = RXReport.car6
car7 = RXReport.car7
car8 = RXReport.car8

TXReport.Message = car1+car2+car3+car4+car5+car6+car7+car8
WriteReport
TXReport.Time = 0

USART.Write (car1,car2,car3,car4,car5,car6,car7,car8)
Cls
DelayMS (30)
WriteAt(1,1,TXReport.Message)
DelayMS (1000)



EndIf




Buffer(0) = 0
Buffer(1) = PORTA.0 // analogique
Buffer(2) = PORTA.0
Buffer(3) = PORTA.1
Buffer(4) = PORTA.2
Buffer(5) = PORTA.3
Buffer(6) = PORTA.4
Buffer(7) = 0
Buffer(8) = 0

WriteArray(Buffer,9)



Wend

If you can my help

Thanks

Joel
Je pense donc je ne suis pas un PC

Post Reply