
Originally Posted by
Darrel Taylor
With SSPM3:0 = 0011, it specifies the SSP clock comes from Timer2/2. But you haven't set-up Timer2.
Since the MAX7219 is a 10mhz device, you can run it at the highest speed available from the PIC.
SSPM3:0 = 0000 -- SPI master mode, clock = FOSC/4
Many thanks Darrel Taylor.
Yes, you are right that's a mistake I have made. I wanted to have SSPM3:0 = 0010, i.e. the lowest speed.
And I think CKE should be 1.
I am not that far, I will check this later on.
In the Main loop, you need to wait for the SSP to finish sending the last byte, before putting a new one in the buffer.
Code:
main:
toggle PORTB.0 ' to see if something is happening
SSPBUF = "A" ' write to SSPBUF to start clock
WHILE !SSPIF : WEND
SSPIF = 0
goto main
If I add this while end loop the PIC stops and never gets further. the PORTB.0 is not blinking any more (check with a scope connected to PORTB.0).
It seems I have a problem with the interrupt setting the SSPIF flag never gets set.
What I did in my code is:
Code:
INTCON = %11000000 ' Set the interrupts, i.e. enable GIE and PEIE
SSPIE = 1 ' Enable SSPIE interrupt
Is there any mistake I have overlooked in my interrupts setting?
Also the MAX7219 needs a Latch(Load) signal from the PIC, to latch the last 16-bit's into the device. Since you're only sending 1 byte, I guess you just haven't made it that far yet though.
<br>
Yes, you are right, I am not that far in the programming. I am adopting rather a pragmatic approach, i.e. doing things step by step.
Thanks a lot.
Bookmarks