Hi,
Is this thread still open?
I would like to ask questions
Camerart
Hi,
Is this thread still open?
I would like to ask questions
Camerart
I’m struggling to find C code in this thread that isn’t directly converted to PBP.
C:
PBP:Code:temp|=DATA;
C falls short of PBP or asm for bitwise operations because you can never access a bit in a single instruction,Code:temp = temp|data'
hence the bit mask is being used in C to only write the set bits in the temp variable.
If you’re clocking the external chip, and then feeding the pic it’s output clock that would normally be a very good ideaCode:B800 = 1011100000000000 DATA = 0000000000001111 B800 | DATA = 1011100000001111
because once you send the command to PLL the external chip's clock higher, both chips are clocked at the higher speed,
and no timing adjustment of the SPI or SHIFTOUT routines should need adjusting,
EXCEPT for the fact that the pic’s instruction clock is divided by 4, so the two chip’s practical instruction timing is not increased evenly,
so you will need two different communication timings for the two different speeds of the external chip.
All of the While loops are the same as PBP While...WEND where the closing brace is WEND.
Code:n=16; while(n--) {dosomething();}Code:n=16; WHILE (n > 0) gosub dosomething’ n = n - 1' WEND
Nops in this function are a delay. The function (subroutine as you worked out) sends a single zero value out of the SPI bus.
If you were to set SCK low, and then high again in the very next instruction, the receiving device might miss the signal.
Especially if the external device runs slower than the transmitting device. You can use @nop in PBP.
Since there are several flavours of SPI, it would be better to reproduce this then use PBP SHIFTOUT (unless it’s already working).
They are really only turning two port bits on & off.
Code:writezero: portb.something = 0’ clear SPI data portb.something = 0’ clear clock pin, the receiver will look at the value of the SPI data bit now. delay portb.something = 1’ set the clock pin, the receiver will look for the next bit on the next rising edge (next time you call this function, or the writeone function).Code:void Write0( void ) { SDI=0; SCK=0; NOP(); NOP(); NOP(); NOP(); NOP(); NOP(); NOP(); NOP(); NOP(); NOP(); NOP(); NOP(); NOP(); NOP(); NOP(); NOP(); SCK=1; NOP(); }
Last edited by Art; - 8th October 2016 at 10:50.
Bookmarks