Dear List,
I am having a strange problem with the SPI
Input/Output block (only used for output in this case).
The code generated by the block seems to be correct, but the
call to WriteSPI1() does not actually drive an output on the pins.
I don't, of course, know what WriteSPI1() actually does. Replacing
it in the generated code with a call to this function works for me:
void my_write_spi(uint16_T value)
{
uint16_T dummy;
if (SPI1STATbits.SPIRBF)
dummy = SPI1BUF;
while (SPI1STATbits.SPITBF)
;
SPI1STATbits.SPIROV = 0;
Nop();
SPI1BUF = value;
} /* End of function my_write_spi() */
Can you suggest what may be going on? I will send copies of the
generated code for a small demonstration model if you like.
I am a software developer working for a small company in England which
produces HIL (hardware-in-the-loop) solutions for various enterprises,
particularly car manufacturers. We want to offer our customers the ability
to generate custom code to run on our hardware, and the dsPIC block-set
looks like a very useful tool. If we get past our current problems, our
customers will become potential customers for the block-set too, but we
need to make it as easy as possible for them.
Bernard Leak.
No SPI output on the pins?
-
- Posts: 18
- Joined: Fri Aug 15, 2008 3:42 pm
- Location: Armitage, Staffordshire, England
-
- Site Admin - Expert
- Posts: 616
- Joined: Wed Mar 07, 2007 11:23 pm
- Location: Bayonne- France
- Contact:
Re: No SPI output on the pins?
hi Bernard,
The function WriteSPI1() is a function from the dsPIC library.
It may be usefull to get the Simulink model file with the problem described to have a look. Could you upload it on the forum ? ( or a simplified version)
Lubin
The function WriteSPI1() is a function from the dsPIC library.
It may be usefull to get the Simulink model file with the problem described to have a look. Could you upload it on the forum ? ( or a simplified version)
Lubin
-
- Posts: 18
- Joined: Fri Aug 15, 2008 3:42 pm
- Location: Armitage, Staffordshire, England
Re: No SPI output on the pins?
Apologies: it was my mistake. I can't work out exactly what I was doing earlier, but the
problem was that my SPI Configuration block didn't have 'SDO Enabled'.
I mistook this for "slave data out" instead of "SPI data out". It all works correctly
now.
On another note, two small corrections to the English on the blocks:
"Block Ordering Input / Ouptut" should be "Block Ordering Input / Output" everywhere
The SPI Configuration block specifically has
"Bus Configuratin Time" which should be "Bus Configuration Time" .
"output change on transition" should probably be "Output Change on Transition"
(all other field headings use capital letters).
Bernard Leak.
problem was that my SPI Configuration block didn't have 'SDO Enabled'.
I mistook this for "slave data out" instead of "SPI data out". It all works correctly
now.
On another note, two small corrections to the English on the blocks:
"Block Ordering Input / Ouptut" should be "Block Ordering Input / Output" everywhere
The SPI Configuration block specifically has
"Bus Configuratin Time" which should be "Bus Configuration Time" .
"output change on transition" should probably be "Output Change on Transition"
(all other field headings use capital letters).
Bernard Leak.
-
- Site Admin - Expert
- Posts: 616
- Joined: Wed Mar 07, 2007 11:23 pm
- Location: Bayonne- France
- Contact:
Re: No SPI output on the pins?
Thanks for theses spelling remarks.
I corrected them all ; Corrections will be available in the next release.
Do you need theses corrections soon ?
Regards
Lubin
I corrected them all ; Corrections will be available in the next release.
Do you need theses corrections soon ?
Regards
Lubin
Who is online
Users browsing this forum: No registered users and 3 guests