What have you on hand to debug? Any PICKit 2, logic analyser, scope?
Any schematic?
I see HS OSC... it mean not much than >4MHz to me
More details, more help.
What have you on hand to debug? Any PICKit 2, logic analyser, scope?
Any schematic?
I see HS OSC... it mean not much than >4MHz to me
More details, more help.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Hi Mister-e
Many thanks for the quick reaction.
As to the schematic nothing special but a PIC 16F876 with a 20 MHz crystal on a Mel PCB (PICPROTO-USB). I am checking with a scope (PCSU1000) the different signals on the PORTC C, i.e. the Serial Data Out (SDO) and the Serial Clock (SCK). Of course my PIC should be a master (or that's what I am trying to achieve).
Of course this works fine with other compilers like MikroC and CCS PICC on other hardware (EasyPIC5). And I want to have it running with PBP.
Please, let me know whether you need further detail on my system.
Last edited by Momboz; - 19th April 2008 at 19:54. Reason: More details
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
And I think CKE should be 1.
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.
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.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
<br>
DT
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.
I am not that far, I will check this later on.And I think CKE should be 1.
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).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
It seems I have a problem with the interrupt setting the SSPIF flag never gets set.
What I did in my code is:
Is there any mistake I have overlooked in my interrupts setting?Code:INTCON = %11000000 ' Set the interrupts, i.e. enable GIE and PEIE SSPIE = 1 ' Enable SSPIE interrupt
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.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>
Thanks a lot.
Sorry DT
I wasn't complete in my previous answer.
The first thing I did was to test with the addition of the while loop as you proposed and it wasn't successful, i.e. No toggle on PORTB.0 signal. It looks like the While loop is blocking the process (or like SSPIF is never set). if I suppress the while loop the PORTB.0 will toggle again.
That's the reason why I thought about setting the interrupts.
Here is some sample code from meLabs. Maybe that would be of help to you.
http://www.melabs.com/resources/samples/pbp/spimast.bas
http://www.melabs.com/resources/samp...p/spislave.bas
Tim Barr
Bookmarks