You may find that routine is actually too fast for the hardware you're controlling.
If so, you can add NOPs to slow it down a bit...
Code:SHDAT = 0 if WREG.0 then SHDAT = 1 endif asm NOP endasm SHCLK = 1 asm NOP endasm SHCLK = 0 asm NOP endasm
You may find that routine is actually too fast for the hardware you're controlling.
If so, you can add NOPs to slow it down a bit...
Code:SHDAT = 0 if WREG.0 then SHDAT = 1 endif asm NOP endasm SHCLK = 1 asm NOP endasm SHCLK = 0 asm NOP endasm
Thanks, that's great!
So if we can replace SHIFTOUT with faster code easily, maybe there is a such way for I2CREAD too? without using MSSP module?
I2C operations are slower to begin with, but you could speed things up over the stock routines.
Having the pins be set in software is what usually slows things down. I've implemented these before and ended up with something around 240KHz with programmable pins.
Dedicated pins speeds it up a lot... think I got around 400KHz doing it that way (running at 64MHz).
You have to watch out with the speed and open-drain IO operation to size the pullups as required.
For faster speeds I like to use active pullups which can really speed up the low-to-high transitions vs using a resistor.
This works out well when using the MSSP since you can get much faster speeds there.
Well, I tried to use MSSP, but no luck, so this is why I'm asking.
Current I2CREAD is too slow, it runs at about 50khz (and is NOT oscillator dependent, as someone stated, I checked with scope, it is around 50khz at 4mhz, 8mhz or 16mhz oscillator speed).
200Khz would be fine for me. I'm using 24C64 as an external font data storage, and at current speed (50khz), reading 1kb of data takes about 1 second, which does looks cool at certain moment - you see how letters are being drawn on the screen, but absolutely not cool for long-time usage.
which PIC device are you using?
looking at some old posts, this thread here http://www.picbasic.co.uk/forum/showthread.php?t=5568 has a number of issues.
Just got to PC today and wanted to run your code, but I have a little problem, my current code looks like this:
SHIFTOUT SDA, SCK, 0, [$C0+row,col]
It sends 2 bytes in a row. How should I do the same with your code?
Just send each byte individually... the result will be the same since SHIFTOUT really does it that way too.
If you're using a PIC16 then you'll have to add a definition for a WREG variableCode:WREG = $C0 + row call SHOUT WREG = col call SHOUT
If you wanted to make the code the same for all devices then change all the references to WREG to a byte variable instead, including the SHOUT subroutine.Code:WREG var byte
Here I've named it SHDATA.
Code:SHDATA var byte SHDATA = $55 call SHOUT
Bookmarks