spihard.bas

来自「82 sample programs written in BASCOM-805」· BAS 代码 · 共 31 行

BAS
31
字号
' -------------------------------------------------------------------
'                       SPIHARD.BAS
'        SPI demo for the hardware SPI found in the 89S8252
' -------------------------------------------------------------------
$regfile = "89s8252.dat"
Const Sim = 1

Dim Ar(10) As Byte
Dim I As Integer

'fill array
For I = 1 To 10
  Ar(i) = I
Next

Config Spi = Hard , Interrupt = Off , Data Order = Lsb , Master = Yes , Polarity = High , Phase = 1 , Clockrate = 4

#if Sim = 0
  Spiin Ar(1) , 10
#endif
'data is sent byte by byte,each byte returned is placed into the array
For I = 1 To 10
  Print Ar(i)
Next


'note that in the simulator the program will halt because the SPSR register will not have the proper value
'that is why we use conditional compilation to exclude the code
End

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?