hey guys,
Im working on a project to create a pretty big robot. and as such, we are using the ARC32 as a means of controlling the servos of the robot, and having an android phone interfacing with the ARC32. We are using it in a smilar fashion to the SSC32, but with movement code and that sort of thing offloaded onto the ARC32.
Anyway, so the problems ive been having are with SPI interfacing. I have the master code set up on the android phone, and so im working on trying to fix the slave SPI on the ARC32. but am having huge problems, i cannot get it to clock in bits at all. and since it is the Slave, it doesnt work to use the SHIFTIN and SHIFTOUT command library. In this case i need to clock in somewhere between 4-8 bits. and in my example code am using 32 for testing.
Does anyone have any suggestions/feedback/help of how i can fix Slave-SPI on the ARC32?
Thanks in advance for all the help and advice, it has been very much appreciated!
Here is the code im currently running, but am having problems with:
[code]'setup vars
baudrate CON i9600
'temp and storage vars
temp VAR WORD 'input var
t VAR BIT
i VAR BYTE 'counting var
j VAR BYTE
'interrupt setup code
IEGR1.bit2 = 1 'sets interrupt to pin 28
PMR1.bit6 = 1 'sets interrupt to be falling edge detection
'interrupt directives
ONINTERRUPT IRQ2INT, sigreceive 'interrupt pin setup directive
ENABLE IRQ2INT 'enables the IRQ2INT on pin 2
ENABLE
'pin constants
CLK_PIN CON P29
Data_pin CON P40
main:
While(1)
Wend
END
sigreceive: 'when handshake pin is high, triggers input interrupt
DISABLE 'disables global interrupts so no compound triggered interrupts occurs
TOGGLE P44 'shows waiting for data
LOW P44 'shows data received
ENABLE 'reenables global interrupts, so data can be read in again
'decode within external interrupt
GOSUB in_data[temp]
RESUME
in_data[temp]:
i = 0
j = 32
WHILE(i<>32)
IF clk_pin = 1 THEN
SERIN Data_pin, [t]
i = i + 1
j = j - 1
ENDIF
temp.bitj = t 'i know this bit is not right, but i want to get it to write to the J-th bit of the var TEMP
WEND[/code]