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 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
Just tried this code and it works, thanks!
But need to use it for shiftout 1 - MSBFIRST.
What should be changed in it?
For MSBFIRST, just change the order of the 'WREG.bit' tests
Code:; SHOUT ; shift out 8 bits of data, MSB to LSB ; data clocked on rising edge of SHCLK ; WREG = data to send SHOUT: SHDAT = 0 if WREG.7 then SHDAT = 1 endif SHCLK = 1 SHCLK = 0 SHDAT = 0 if WREG.6 then SHDAT = 1 endif SHCLK = 1 SHCLK = 0 SHDAT = 0 if WREG.5 then SHDAT = 1 endif SHCLK = 1 SHCLK = 0 SHDAT = 0 if WREG.4 then SHDAT = 1 endif SHCLK = 1 SHCLK = 0 SHDAT = 0 if WREG.3 then SHDAT = 1 endif SHCLK = 1 SHCLK = 0 SHDAT = 0 if WREG.2 then SHDAT = 1 endif SHCLK = 1 SHCLK = 0 SHDAT = 0 if WREG.1 then SHDAT = 1 endif SHCLK = 1 SHCLK = 0 SHDAT = 0 if WREG.0 then SHDAT = 1 endif SHCLK = 1 SHCLK = 0 return
Thank you again!
Only today I managed to adapt this code to my hardware and it works very fast!
But I have a question, WREG is not an variable, but a register name, right?
It works fine without definition on PIC16F1828.
In fact, if I add definition, compiler gives an error - Redefiniton of VAR
This is why I asked![]()
If you're using an enhanced midrange PIC16 device (like the PIC16F1828) then it has a WREG, so it works with them too without having to declare a 'WREG' variable.
It's only for the older PIC16's you'd have to define it, or just change all the references to WREG to a new variable name of your choice.
The above code works fine with TM1629A display.
But it does not work properly with APA102C leds.
I have the following statement:
SHIFTOUT di, ci, 1,[224+Bri[x],COLORS[X+16],COLORS[X+8],COLORS[X]]
Which I have replaced with
wreg=224+Bri[x]
gosub shout
wreg=COLORS[X+16]
gosub shout
wreg=COLORS[X+8]
gosub shout
wreg=COLORS[X]
gosub shout
The issue is that only odd bytes got transferred.
Say if I set some value to 2 or 4 it gets delivered to LEDs, but if I set it to 1 or 3 or 5 - nothing happens.
Tried to insert pause between each subroutine call - no difference
I also tried to add some NOPs as suggested above - no difference.
Bookmarks