PDA

توجه ! این یک نسخه آرشیو شده میباشد و در این حالت شما عکسی را مشاهده نمیکنید برای مشاهده کامل متن و عکسها بر روی لینک مقابل کلیک کنید : کار با ad7730



amisa
26-08-2013, 01:15
باسلام وخسته نباشید به دوستان محترم :
میخواستم ad7730رو به میکرو وصل کنم اما پایه rdyیک است وصفر نمیشه ا این هم نمونه برنامه
تمام ریجسترهاشو نوشتم

$regfile = "m32def.dat"
$crystal = 4000000

Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Pina.2 , Db5 = Pina.3 , Db6 = Pina.4 , Db7 = Pina.5 , Rs = Pina.0 , E = Pina.1

Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 4 , Noss = 1

Enable Spi

'************************************************* ************************
Dim Status_registerr1 As Byte
Dim Status_registerr2 As Byte
Dim Status_registerr3 As Byte

Dim Data_registerr1 As Byte
Dim Data_registerr2 As Byte
Dim Data_registerr3 As Byte

Dim Mode_registerr1 As Byte
Dim Mode_registerr2 As Byte
Dim Mode_registerr3 As Byte

Dim Filter_registerr As Byte

Dim Dac_registerr As Byte

Dim Offset_registerr As Byte

Dim Gain_registerr As Byte

Dim Test_registerr As Byte

Dim Communications_registerw As Byte

Dim Mode_registerw As Byte

Dim Filter_registerw As Byte

Dim Dac_registerw As Byte

Dim Offset_registerw As Byte

Dim Gain_registerw As Byte
'"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Dim Lsb_data As Word
Dim Msb_data As Byte
Dim All_data As Word
Dim Data_read As String * 16
'""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
'************************************************* ********************
'khandan register
Status_registerr1 = &H10
Status_registerr2 = &H20
Status_registerr3 = &H30
'----------------------------------
Data_registerr1 = &H11
Data_registerr2 = &H21
Data_registerr3 = &H30
'----------------------------------
Mode_registerr1 = &H12
Mode_registerr2 = &H22
Mode_registerr3 = &H30
'----------------------------------
Filter_registerr = &H13
'----------------------------------
Dac_registerr = &H14
'----------------------------------
Offset_registerr = &H15
'----------------------------------
Gain_registerr = &H16
'----------------------------------
Test_registerr = &H17
'----------------------------------
'************************************


'************************************
'nevshtan register ha
'************************************
Communications_registerw = &H00
'------------------------------------
Mode_registerw = &H02
'------------------------------------
Filter_registerw = &H03
'------------------------------------
Dac_registerw = &H04
'------------------------------------
Offset_registerw = &H05
'------------------------------------
Gain_registerw = &H06
'----------------------------------------
'*******************************************
Config Portb.0 = Input
Config Portb.1 = Output
Config Portb.2 = Output
Data_ready Alias Pinb.0
Chip_select Alias Pinb.1
Reset_chip Alias Pinb.2
'********************************************
Dim C30 As Byte



Cursor Off
Cls

Spiinit




Wait 2
Reset_chip = 0
Waitus 100
Reset_chip = 1
Chip_select = 0
'Spiout Communications_registerw , 1
'Spiout Status_registerr1 , 1
'C30 = Communications_registerw , 1

C30 = Status_registerr3
Spiout Communications_registerw , 1
Wait 2
Spiout Status_registerr1 , 1


Do
Chip_select = 0
Bitwait Data_ready , Reset

Lsb_data = Spimove(c30)
'Spiin Lsb_data , 1
Home
Lcd "val:" ; Lsb_data ; ""
Home L
Lcd "out:" ; C30 ; ""




'Spiin Lsb_data , 2
'Spiin Msb_data , 1

'Waitms 10
'All_data = Makeint(lsb_data , Msb_data)
'Data_read = Str(all_data)




Loop