LC Display Dig 2R a 2 x 4digit 7segment Display

woschx

New Member
Can someone tell me how to control the display?
It only has 4 connections: GND, VCC, Data, Clk
The two 4 x 7 digits displays are addressed via two shift registers 74HC164 but I can't find anywhere how to address a specific display.

Greetings

Wolfgang
 

hippy

Technical Support
Staff member
Unfortunately there doesn't seem to be much data on the board which I could find.

It does however look like the display is indeed controlled by two 74HC164 chips or similar, so, with those being 8-bit shift-registers, plus 64-segments on the displays in total, I would guess they are wired as a matrix. Send 8-bits of row select data, 8-bits of column select data, the appropriate segment(s) will then light.

As to whether it's 8-bit row then 8-bit column, or vice-versa, or some sort of mix, which are active low and which are active high, would have to be determined by experimentation.

I would guess that sending one of these pairs would light a single segment -
Code:
%00000001 %00000001
%00000001 %11111110
%11111110 %00000001
%11111110 %11111110
Once one segment alone lights, you can then try other combinations to figure out how everything is mapped, which bits mean what.

But you need to be careful because lighting multiple segments could overload the board, burn out the chips. I would ensure you have the board powered from a bench PSU with current limiting turned way down.

The problem is though; this appears to be a 'one segment lit at a time' board, needs to be continually driven to light all the displays one segment at a time. Doing that well is going to be a tough ask for a PICAXE, even at highest operating speeds.

There do seem to be 8 resistors on the board so there is some degree of current limiting per segment, but I wouldn't want to linger on one particular segment being lit without knowing what the resistor values are.

It the resistors are suitable it might be possible to do one digit at a time which is easier for a PICAXE to handle.

You would however be much better off using a MAX7219 display board.
 

woschx

New Member
Thanks for your information!
I only found this minidocu, but it doesn't really make sense.

This module is ideally suited to adding a 2 line 4 digit red 7 segment display to your project. This module lets you display your information in a bold and bright way, writing all manners of numbers and words with numbers from 0-9, A-F, - and . .

The module is designed for use on its own or combined with other modules to create larger displays. This module has Red LEDS that are powered via a serial connection to a microcontroller.

Particular characters are generated by taking a two digit Hex value then using an AND function with 0x80. Using the newly created Hex value you drive the CP pin LOW, send the data on the DAT pin and then set CP to HIGH. This of course needs to be performed quickly for persistence of vision (appear constant) to kick in.

Grettings

Wolfgang
 

westaust55

Moderator
The displays could be configured as an 8 x 8 line matrix as hippy has suggested.

alternatively based on some single 4-digit 7-segment (with dp) displays I have used they could be configured as:
- all the like segments connected together (I.e. all 8 “a” segments together) with one shift register to select the desired pattern for 1 digit, and
- each digit/character having a separate common anode/cathode line with one shift register output per digit.

either way needs the microcontroller to keep refreshing the display.
the entire one digit at a time as per my thoughts would be a little easier.

you then need to ascertain if the displays are common anode or common cathode then set the data for the two shift registers correctly.
Driving multiple digits at the same instant could overload the shift register for the common lines.

The 74164 shift register IC’s do not have latching outputs (the 74595 does) so I believe there will be a visible “ripple” seen on the displays if all digits are not off while new segment data is clocked in but if only one each of data and clock lines that is likely not achieveable.
 

hippy

Technical Support
Staff member
The 74164 shift register IC’s do not have latching outputs (the 74595 does) so I believe there will be a visible “ripple” seen on the displays if all digits are not off while new segment data is clocked in
Good point. Which means each set of data has to be clocked in and out at a fast rate to avoid bleed on other segments. That, I would have thought, would be rather infeasible for segment at a time multiplexing, so that hints at it more likely being intended to be a digit at a time.

Found the manufacturer's product page, but can't see anything which leads to a PDF -

http://www.lctech-inc.com/cpzx/2/qtmk/2019/0116/344.html

None of the retailers or ebay sellers seem to have a datasheet or schematic. But I think we've figured out how it works, just need to drive it and figure out polarities and bit allocations.
 

inglewoodpete

Senior Member
I'd be using the hardware SPI feature on an X2-series PICAXE. hSPI output can be very fast, meaning that segments that are 'stepped over' during a register refresh will not be visible. Viewing the magnified image from the manufacturer's webpage, I can see that the resistors are marked 102. This suggests current limiting of 1000 ohms per segment, which should make the segments fine for 5 volt operation.
I would guess that sending one of these pairs would light a single segment -
Code:
%00000001, %00000001
%00000001, %11111110
%11111110, %00000001
%11111110, %11111110
Once one segment alone lights, you can then try other combinations to figure out how everything is mapped, which bits mean what.
I would structure some test code that you hSPIOut one pair of numbers ("data pair") that hippy suggests, a pause of 10mS, followed by a second hSPIOut sending %00000000, %00000000 (Ie 0,0), then a pause of 40mS before looping back to send the data pair again.
 

westaust55

Moderator
From the Banggood website and the markings shown there on the side of the 4-digit 7-segment display as "3461BS"
this is a common anode type display.

For the individual 3461BS displays, found from various sources the pinout as:
3461BS Pinout.png3461BS.png


A little bit of tracing of the circuit on the PCB by the OP should now help determine:
1. which 74HC164 is driving the segments (and output to which of the segments "a" to "f" and the dp)
2. which 74HV164 is controlling the digit anodes (and which output drives which of the 8 digitals)

Then prepare some code where:
1. On the 74HC164 for the segments make the required outputs low = 0 (cathodes sink the current) and all others high
2. On the 74HC164 for digit selection make the required output for that digit high (=1) and all the others low.
 

Attachments

AllyCat

Senior Member
Hi,

Ah, quite a lot of progress whilst I've been asleep. :) I had "expected" common-cathode and/or NPN digit-driver transistors as being the most "favourable", but could there be any "hidden" PNPs ? These were my thoughts last night which might still have some relevance:

Yes, I would guess that it could be used digit by digit, so needs an update rate of about 500 Hz (2 ms), perhaps a little tight for a PICaxe unless using some hardware assistance like SPI. The text implies that CP also acts as a "display enable", so during loading would be kept predominantly low, pulsing high as quickly as possible, then taken high for display.

I would expect there to be 7 - 8 current-limiting resistors (one for each segment, shared by all digits) which should help to limit the current if inappropriate data is loaded (or during intermediate transients). Perhaps also 8 "digit driver" transistors (and associated base resistors) or FETs, or just assuming that pull-down FETs tend to be "stronger" than pull-ups in ICs. If there are NO (inverting/buffer) transistors, then "all bits high" or "all low" should be "safe" (off) and a single bit of opposite polarity should illuminate one segment or one digit. WITH transistors, probably the data for one register would need to be inverted relative to the other (for all off). Then, transmit "Hex" data for one register, "1 of 8" (digit select) for the other.

An "inspection" of the PCB may reveal any resistors and transistors,, etc., but of course some might be "hidden" under the displays. With independent control of all segments it's possible to display not only all the (Hex) digits, 0 - 9 A b C d E F, but g H J L n o p r t u y if carefully choosing the segments for o/0 4/y b/6 9/g (the former with less segments lit). Depending on one's creativity, most lower-case letters are "possible" but not necessarily distinguishable from upper case or some numbers.

Cheers, Alan.
 
Last edited:

inglewoodpete

Senior Member
I would expect there to be 7 - 8 current-limiting resistors (one for each segment, shared by all digits) which should help to limit the current if inappropriate data is loaded (or during intermediate transients).
Cheers, Alan.
Refer to my post. 2 x 74HC164, 8 resistors (appear to be "102" - 1000ohms), no transistors, 4-wire interface, 5 volt working.
Edit: Corrected 101 to 102 (I blame the keyboard :))
 
Last edited:

woschx

New Member
Today I measured the board a little bit.
The first byte is used to compose the segments and the second byte is used to select which of the eight digits should display it.
With the clock input the data is pushed bit by bit into the display.
Since all bits are pushed through the selection byte, the respective digit is activated with every bit which is 1.
Therefore all digits will inevitably always flicker. After each digit a small pause must be set so that this digit is clearly illuminated.
Since the transmission of a new digit deletes the previous one, there are two possibilities.
1. the waiting time is set very small then you can't see any difference between the dark and the light segments with 8 digits but it doesn't flicker because they all shine almost equally bright
2. the waiting time is set high then you get a kind of running light with a display that runs through which also makes no sense!
I have no idea how you can get a usable display with this part, with whatever processor!

For each digit I can display any number or letter but with 8 digits I can't control the flickering and the different brightness of the segments!
Maybe I make a mistake in my thinking but at the moment I can't think of anything else.
Here I have my test program:
 

Attachments

woschx

New Member
I think the key is the speed with which you can get the data into the display!
This routine is too slow!
How could you speed up the output?

for i = 0 to 7
temp = val & %00000001
; mask bit 0 using bitwise AND
if temp = 1 then HIGH dat
else LOW dat
endif
pulsout CLK,1 ; clock bit into register
val = val / 2 ; shift bits one place right
next i

for i = 0 to 7
temp = stelle & %00000001
; mask bit 0 using bitwise AND
if temp = 1 then HIGH dat
else LOW dat
endif
pulsout CLK,1 ; clock bit into register
stelle = stelle / 2 ; shift bits one place right
next i
 

AllyCat

Senior Member
Hi,
Refer to my post. 2 x 74HC164, 8 resistors (appear to be "101" - 1000 ohms), no transistors, ....
No, I didn't edit my drafted post (from last night) on what I had expected (or hoped) to find.

Isn't 101 = 100 ohms ? But IMHO even 1k (/ 8) is "pushing it" with no driver transistor. The nominal pull-up impedance of a 74HC164 output pin is about 150 ohms at 5v, whilst it's less than 40 ohms pull-down (from the Nexperia/NXP/Philips data sheet).

@woschx : I've only very briefly looked at your (first) program so far, but it can very probably be increased considerably in speed. Which PICaxe chip are you using? Firstly, don't use any subroutines in a fast main loop (use macros instead, if you wish). Also, I believe you are leaving CP low during the Pause (display time) which I think might need to be high (or maybe the text just means that data is clocked in on the positive edges ?).

Cheers, Alan.
 

woschx

New Member
I use the 18M2
The data is only clocked with the positiv edges of the CP.
If the bits are only applied to the data input but then no clock is received, they cannot be transferred into the display.
This is not possible!
 

AllyCat

Senior Member
Hi,

Yes, I was probably trying to read too much into the statement:
send the data on the DAT pin and then set CP to HIGH.
Just a few quick tips on PICaxe speed (with the M2 family):
Left-shifting (stelle = stelle + stelle ) is about twice as fast as right-shifting (division).
Bit operations using b0 - b3 (e.g. dat = bitn ) should be faster than logic plus IF .. THEN operations.
For much better speed, "unroll" the FOR .. NEXT loops into linear code.

Cheers, Alan.
 

hippy

Technical Support
Staff member
I would give this a whirl ...
Code:
#Picaxe 18M2
#No_Data

Symbol DAT    = C.0 : Symbol DATpin = pinC.0 
symbol CLK    = C.1

symbol val    = b0
symbol stelle = b1

Main:
  SetFreq M32
  Low CLK
  Low DAT
  Do
    val =   3 : Gosub Display
    val = 127 : Gosub Display
    val = 127 : Gosub Display
    val =  64 : Gosub Display
    val =  32 : Gosub Display
    val =  16 : Gosub Display
    val =   8 : Gosub Display
    val =   4 : Gosub Display
  Loop
  
Display:
  stelle = stelle + stelle And $FF Min 1
  DATpin = bit7  : PulsOut CLK, 1
  DATpin = bit6  : PulsOut CLK, 1
  DATpin = bit5  : PulsOut CLK, 1
  DATpin = bit4  : PulsOut CLK, 1
  DATpin = bit3  : PulsOut CLK, 1
  DATpin = bit2  : PulsOut CLK, 1
  DATpin = bit1  : PulsOut CLK, 1
  DATpin = bit0  : PulsOut CLK, 1
  DATpin = bit8  : PulsOut CLK, 1
  DATpin = bit9  : PulsOut CLK, 1
  DATpin = bit10 : PulsOut CLK, 1
  DATpin = bit11 : PulsOut CLK, 1
  DATpin = bit12 : PulsOut CLK, 1
  DATpin = bit13 : PulsOut CLK, 1
  DATpin = bit14 : PulsOut CLK, 1
  DATpin = bit15 : PulsOut CLK, 1
  Pause 40
  Return
The digit order may be reversed, segments also, but that can all be sorted out by rearranging the "DATpin = bitN" order.

Making the PAUSE larger should improve brightness, reducing it should reduce flicker but too low and things will start to blur.

If CLK should be high at the end as AllyCat theorises, change ...
Code:
  DATpin = bit15 : PulsOut CLK, 1
  Pause 40
to
Code:
  DATpin = bit15 : High CLK
  Pause 40
  Low CLK
 
Last edited:

hippy

Technical Support
Staff member
It looks like "DATpin = bit7" does not set the output
You are right. Add a "Low DAT" after the existing "Low CLK". I have updated my earlier post.

Sorry about that. I originally had that in there but decided I didn't need it because "DATpin=" always sets an initial level before clocking. I forgot that taking it out means it's never made an output - Oops.
 

woschx

New Member
Thanks a lot.
This is how the program now runs and shows the numbers 1 to 8 from top left to bottom right.
If you put one or two sheets of paper over the display, the dark segments are almost completely hidden and the numbers are easy to read. Nothing flickers anymore.
You could speed up the process even more by displaying all 8 digits in a routine. That would save 8 calls of the subroutine.

Now I will call the display routine with an interrupt so I can do other things in between.
-----------------------------------------------
Code:
#Picaxe 18M2
#No_Data

;leer = 255
;Punkt = 254
;0 = 3
;1 = 159
;2 = 37
;3 = 13
;4 = 153
;5 = 73
;6 = 65
;7 = 31
;8 = 1
;9 = 9

Symbol DAT    = C.0 : Symbol DATpin = pinC.0
symbol CLK    = C.1

symbol val    = b0
symbol stelle = b1

SetFreq m32

Low CLK
Low DAT
Main:

  Do
    stelle = 128
    val =   1 : Gosub Display   ;8. Stelle   
    val = 31 : Gosub Display   ;7. Stelle
    val = 65 : Gosub Display   ;6. Stelle
    val =  73 : Gosub Display   ;5. Stelle

    val =  153 : Gosub Display   ;4. Stelle
    val =  13 : Gosub Display   ;3. Stelle
    val =   37 : Gosub Display   ;2. Stelle
    val =   159 : Gosub Display   ;1. Stelle
  Loop
 
Display:
  stelle = stelle + stelle And $FF Min 1
  DATpin = bit0  : PulsOut CLK, 1
  DATpin = bit1  : PulsOut CLK, 1
  DATpin = bit2  : PulsOut CLK, 1
  DATpin = bit3  : PulsOut CLK, 1
  DATpin = bit4  : PulsOut CLK, 1
  DATpin = bit5  : PulsOut CLK, 1
  DATpin = bit6  : PulsOut CLK, 1
  DATpin = bit7  : PulsOut CLK, 1
 
  DATpin = bit8  : PulsOut CLK, 1
  DATpin = bit9  : PulsOut CLK, 1
  DATpin = bit10 : PulsOut CLK, 1
  DATpin = bit11 : PulsOut CLK, 1
  DATpin = bit12 : PulsOut CLK, 1
  DATpin = bit13 : PulsOut CLK, 1
  DATpin = bit14 : PulsOut CLK, 1
  DATpin = bit15 : PulsOut CLK, 1
  Pause 25 ;40 for m16
  Return
 

AllyCat

Senior Member
Hi,

Effectively, all the program code before the first PulsOut and after the last PulsOut just adds to the PAUSE (digit display) time, so there isn't much advantage in speeding up that part of the program. :(

The second group of pulses (bit8 - bit15 = stelle) only needs to have one period with DATpin = 1 and a variable number of pulses before and after, which might be possible to code more efficiently. However, I've looked at ON ... GOTO and SEROUT (which could use a single character to generate from 1 to 5 pulses), but they don't appear to offer any useful improvement. HSEROUT might be possible but is limited to just one or two pins.

If I wanted to really increase the performance, I'd look at accessing the SPI hardware (which is also present in M2 chips), using POKESFR commands.

I don't think that M2s have an internal timer interrupt facility, but it could be arranged by externally linking a PWM output to an Interruptable input. Or of course an X2 has double the clock speed, SPI firmware and an internal timer interrupt. ;)

Cheers, Alan.
 

inglewoodpete

Senior Member
@alan - While I was sleeping, a lot has happened! I mistyped way back in post #9: the resistors are actually marked "102". I agree that the 74HC164 is "suboptimal" for this task, with Iout(max) = 25mA. (~3mA/pin divided by 8 = I(segment average) = 375uA)

Driving this display with an M2 will be a compromise at best. It should be possible with an X2, using hSPIOut at 63kbits/S, 250kbits/s or even 1Mbits/S. This should give a little time for the PICAXE to do some other tasks, in small chunks. I'd be programming a PIC in C, but then, I'd probably use a different display!
 

hippy

Technical Support
Staff member
Using HSPIOUT or SHIFTOUT should improve the transfer speed. HSEROUT is indeed another possibility for fast pulsing, and setting HSEROUT up for synchronous transmission allows an SPI-like, data and clock output so that's another option.

Having the main program interrupted to keep the display refreshed is an interesting challenge. The X2's have SETTIMER which can generate a repeatable timed interrupt which makes that easy. For an M2 one would need some other mechanism.

Two thoughts there are to use an external pin and an RC so the C can be discharged and the interrupt happens once it's charged, the interrupt zeroes it, or a 555. Or it may be possible to use multi-tasking, proof of concept which shows the Start2 display routine interleaves with the main Start0 program -
Code:
Start0:
  Do
    w7 = w7 + 1
    b3 = w7 / 10000      + "0" : SerTxd(b3)
    b3 = w7 / 1000 // 10 + "0" : SerTxd(b3)
    b3 = w7 / 100  // 10 + "0" : SerTxd(b3)
    b3 = w7 / 10   // 10 + "0" : SerTxd(b3)
    b3 = w7        // 10 + "0" : SerTxd(b3)
    SerTxd(CR)
    SerTxd(LF)
  Loop

Start1:
  Do
    Pause 40
    Suspend 0
    Resume  2
    Resume  0
  Loop

Start2:
  Suspend 2
  Do
    Suspend 1
    b0 = $80 : Gosub Display
    b0 = $40 : Gosub Display
    b0 = $20 : Gosub Display
    b0 = $10 : Gosub Display
    b0 = $08 : Gosub Display
    b0 = $04 : Gosub Display
    b0 = $02 : Gosub Display
    b0 = $01 : Gosub Display
    Resume  1
    Suspend 2
  Loop

Display:
  SerTxd("*")
  Return
Bottom line is I'd use an X2, HSPI and SETTIMER. Much easier.
 

woschx

New Member
Is it possible with Hi2cout ?
400Khz are already quite fast!
And all M2 know the hi2cout.
 
Last edited:

westaust55

Moderator
Is it possible with Hi2cout ?
400Khz are already quite fast!
And all M2 know the hi2cout.
No the Hi2cOut command is for i2c bus comms, whereas the 74HC164 chips are simple serial devices with data and clock lines.

Hippy has earlier mentioned the HSPIout and the SHIFTOUT command which (from memory) is around 4 times faster than bit-bang methods for the same clock speed.
NOTE: the SHIFTOUT command is only available for the PICAXE X2 and older X1 parts.
 

woschx

New Member
This is exactly the problem that I don't want to use an X1 or X2 but just an M or M2!
I'm not quite sure why I can't do a transfer with I2C, even though the 74HC164 is not an I2C chip! The data is shifted out and arrives in the 74HC164 as usual bit by bit!
I know that the I2C is not designed for this but why should this not work?
 

Buzby

Senior Member
I'm not quite sure why I can't do a transfer with I2C, even though the 74HC164 is not an I2C chip!... I know that the I2C is not designed for this but why should this not work?
I2C is not just two wires, it's a protocol. A telephone is two wires, but if you don't speak the same language as the person on the other end you can't communicate. Same with I2C and SPI, they are different languages.
 

hippy

Technical Support
Staff member
I know that the I2C is not designed for this but why should this not work?
It won't work because I2C is not designed to do what is required, cannot do what is required. The signals which I2C puts out are very different to what the display requires.

This is exactly the problem that I don't want to use an X1 or X2 but just an M or M2!
Though HSPI is not supported by the M2 through the Basic commands, it may be possible to utilise the on-chip SPI capabilities of an M2 through judicious use of POKESFR commands. Untested, and digit and segment order may not be correct ...

Edits : Added SSP1STAT, CKP=0, CKE=1, SSPM=0010

Code:
#Picaxe 18M2
#No_Data

Symbol SDI      = B.1 ; Not used
Symbol SDO      = B.2 ; To display DAT
Symbol SCK      = B.4 ; To display CLK

; SFR

Symbol SSP1BUF  = $91 ; $211
Symbol SSP1STAT = $94 ; $214
Symbol SSP1CON1 = $95 ; $215
Symbol SSP1CON3 = $97 ; $217

; SSP1STAT

Symbol SSP1STAT_BF_BIT     = bit0
Symbol SSP1STAT_UA_BIT     = bit1
Symbol SSP1STAT_R_nW_BIT   = bit2
Symbol SSP1STAT_S_BIT      = bit3
Symbol SSP1STAT_P_BIT      = bit4
Symbol SSP1STAT_D_nA_BIT   = bit5
Symbol SSP1STAT_CKE_BIT    = bit6
Symbol SSP1STAT_SMP_BIT    = bit7

; SSP1CON1

Symbol SSP1CON1_SSPM0_BIT  = bit0
Symbol SSP1CON1_SSPM1_BIT  = bit1
Symbol SSP1CON1_SSPM2_BIT  = bit2
Symbol SSP1CON1_SSPM3_BIT  = bit3
Symbol SSP1CON1_CKP_BIT    = bit4
Symbol SSP1CON1_SSPEN_BIT  = bit5
Symbol SSP1CON1_SSPOV_BIT  = bit6
Symbol SSP1CON1_WCOL_BIT   = bit7

; SSP1CON3

Symbol SSP1CON3_DHEN_BIT   = bit0
Symbol SSP1CON3_AHEN_BIT   = bit1
Symbol SSP1CON3_SBCDE_BIT  = bit2
Symbol SSP1CON3_SDAHT_BIT  = bit3
Symbol SSP1CON3_BOEN_BIT   = bit4
Symbol SSP1CON3_SCIE_BIT   = bit5
Symbol SSP1CON3_PCIE_BIT   = bit6
Symbol SSP1CON3_ACKTIM_BIT = bit7

Symbol val      = b0
Symbol stelle   = b1

Init:
  SetFreq M32
  Low SDO
  Low SCK

  SSP1STAT_BF_BIT     = 0
  SSP1STAT_UA_BIT     = 0
  SSP1STAT_R_nW_BIT   = 0
  SSP1STAT_S_BIT      = 0
  SSP1STAT_P_BIT      = 0
  SSP1STAT_D_nA_BIT   = 0
  SSP1STAT_CKE_BIT    = 1
  SSP1STAT_SMP_BIT    = 0
  PokeSfr SSP1STAT, b0

  SSP1CON1_SSPM0_BIT  = 0
  SSP1CON1_SSPM1_BIT  = 1
  SSP1CON1_SSPM2_BIT  = 0
  SSP1CON1_SSPM3_BIT  = 0
  SSP1CON1_CKP_BIT    = 0
  SSP1CON1_SSPEN_BIT  = 1
  SSP1CON1_SSPOV_BIT  = 0
  SSP1CON1_WCOL_BIT   = 0
  PokeSfr SSP1CON1, b0

  SSP1CON3_DHEN_BIT   = 0
  SSP1CON3_AHEN_BIT   = 0
  SSP1CON3_SBCDE_BIT  = 0
  SSP1CON3_SDAHT_BIT  = 0
  SSP1CON3_BOEN_BIT   = 0
  SSP1CON3_SCIE_BIT   = 0
  SSP1CON3_PCIE_BIT   = 0
  SSP1CON3_ACKTIM_BIT = 0
  PokeSfr SSP1CON3, b0

Main:
  Do
    val =   1 : Gosub Display   ;8. Stelle   
    val =  31 : Gosub Display   ;7. Stelle
    val =  65 : Gosub Display   ;6. Stelle
    val =  73 : Gosub Display   ;5. Stelle
    val = 153 : Gosub Display   ;4. Stelle
    val =  13 : Gosub Display   ;3. Stelle
    val =  37 : Gosub Display   ;2. Stelle
    val = 159 : Gosub Display   ;1. Stelle
  Loop

Display:
  stelle = stelle + stelle And $FF Min 1 
  PokeSfr SSP1BUF, val
  PokeSfr SSP1BUF, stelle
  Pause 25
  Return
 
Last edited:

hippy

Technical Support
Staff member
Turns out SSP1CON1 was tricky to get right; presumably some firmware interaction, but this seems to work for sending faked HSPI on an 18M2. About 75us per byte at 32MHz, data clocked on rising edge of SCK.
Code:
#Picaxe 18M2
#No_Data

Symbol SDI      = B.1 ; Not used
Symbol SDO      = B.2 ; To display DAT
Symbol SCK      = B.4 ; To display CLK

; SFR

Symbol SSP1BUF  = $91 ; $211
Symbol SSP1STAT = $94 ; $214
Symbol SSP1CON1 = $95 ; $215
Symbol SSP1CON3 = $97 ; $217

Init:
  SetFreq M32
  Low SDO
  Low SCK

  PokeSfr SSP1STAT, %01000000
  PokeSfr SSP1CON1, %00100010
  PokeSfr SSP1CON3, %00000000

Main:
  Do
    PokeSfr SSP1BUF, %11111100
    PokeSfr SSP1BUF, %10010110
    Pause 1
  Loop
 
Top