
Originally Posted by
marcasjr
I use Proton+ PICbasic from Crownhill, I use Proteus ISIS Professional as Simulator...
Proton <> PBP _ Crownhill sponsors their forum too, and also sells that compiler.
Your Code as posted with my comments in red:
Code:
Device 16F877A
XTAL = 20 <font color=red> DEFINE OSC 20</font color>
ALL_DIGITAL = TRUE <font color=red> Not in PBP
The following will work but there are better ways.</font color>
Symbol CS = PORTC.4 ' SPI eeprom CS line
Symbol SCK = PORTC.3 ' Clock pin
Symbol SI = PORTC.5 ' Data in pin
Symbol SO = PORTC.5
<font color=red> Like . . .
CS VAR PortC.4
No Dims in PBP </font color>
Dim reg as BYTE
Dim datas[10] as BYTE
Dim dongu as BYTE
<font color=red> do it this way
Dongu VAR BYTE
Datas VAR BYTE[10]</font color>
MAX6952_Init:
PORTC.0=0
FOR dongu = 1 to 2
Shout SI, SCK, MSBFIRST, [0x04]
Shout SI, SCK, MSBFIRST, [0x01]
NEXT
PORTC.0=1
PORTC.0=0
PORTC.0=0
FOR dongu = 1 to 2
Shout SI, SCK, MSBFIRST, [0x01]
Shout SI, SCK, MSBFIRST, [0xFF]
NEXT
PORTC.0=1
PORTC.0=0
PORTC.0=0
FOR dongu = 1 to 2
Shout SI, SCK, MSBFIRST, [0x02]
Shout SI, SCK, MSBFIRST, [0xFF]
NEXT
PORTC.0=1
PORTC.0=0
PORTC.0=0
FOR dongu = 1 to 2
Shout SI, SCK, MSBFIRST, [0x03]
Shout SI, SCK, MSBFIRST, [0x01]
NEXT
PORTC.0=1
PORTC.0=0
Return
max6952_putchar:
PORTC.0=0
FOR dongu = 1 to 2
Shout SI, SCK, MSBFIRST, [reg]
Shout SI, SCK, MSBFIRST, [datas[0]]
NEXT
PORTC.0=1
PORTC.0=0
Return
Main:
TRISC=%010001100
Goto MAX6952_Init
reg=0x20
datas[0]="A"
Goto max6952_putchar
Delayms 500<font color=red> Nope! Pause 500</font color>
Goto main
That should give you something to chew on a while.
Bookmarks