Searching \ for ' [PIC] Anybody know how to send 21 words' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'Anybody know how to send 21 words'.

No exact or substring matches. trying for part
PICList Thread
'[PICLIST] [PIC] Anybody know how to send 21 words '
2000\08\29@183802 by Ed Troy

flavicon
face
I need to use a PIC 16c74 to program a National Semiconductor LMX2306
synthesizer. To program this device, I need to send out 3 21 bit words over
the SPI bus. I am using a Hi-Tech C compiler. Does anybody know a simple
way to do this. A pointing to some sample code would be greatly
appreciated. I have been looking for a long time, but have not had much
luck finding what I need.

TIA,
Ed

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu>

2000\08\30@033351 by Michael Rigby-Jones

flavicon
face
> -----Original Message-----
> From: Ed Troy [SMTP:.....etroyKILLspamspam@spam@AEROCONSULT.COM]
> Sent: Tuesday, August 29, 2000 11:38 PM
> To:   PICLISTspamKILLspamMITVMA.MIT.EDU
> Subject:      [PIC] Anybody know how to send 21 words out over SPI in C?
>
> I need to use a PIC 16c74 to program a National Semiconductor LMX2306
> synthesizer. To program this device, I need to send out 3 21 bit words
> over
> the SPI bus. I am using a Hi-Tech C compiler. Does anybody know a simple
> way to do this. A pointing to some sample code would be greatly
> appreciated. I have been looking for a long time, but have not had much
> luck finding what I need.
>
> TIA,
> Ed
>
>
The internal SPI is based on 8 bit words, as your requirement is not a
multiple of 8 you will have to use software SPI (bit bashing).  Check the
data sheet to see on which clock edge the data is written into the device,
and use a small loop to clock out the data.  Full SPI actually transmits and
recieves at the same time. Do you need to clock 21 bits of data back into
the PIC at the same time, or is this purely a one way link?

For transmit only, something like this should suffice.  It would be pretty
trivial to add a 21 bit receive to this:

(SDO and SCK are serial data and clock pins defined elsewhere in your
project, you need to make sure they are configured as outputs)

void SPI_21bit (long spidata)
{
       char bitcount;
       for(bitcount=21;bitcount--;)
       {
               SDO = (spidata & 0x200000)? 1:0;        /* set data out pin
according to bit 21 */
               SCK = 1;
/* clock high */
               spidata <<= 1;                                          /*
shift data left one place */
               SCK = 0;
/* clock low */
       }
}


Hope this helps.

Mike

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
"[PIC]:" PIC only "[EE]:" engineering "[OT]:" off topic "[AD]:" ad's

2000\08\30@080513 by mike

flavicon
face
On Wed, 30 Aug 2000 08:32:49 +0100, you wrote:

>> -----Original Message-----
>> From: Ed Troy [SMTP:.....etroyKILLspamspam.....AEROCONSULT.COM]
>> Sent: Tuesday, August 29, 2000 11:38 PM
>> To:   EraseMEPICLISTspam_OUTspamTakeThisOuTMITVMA.MIT.EDU
>> Subject:      [PIC] Anybody know how to send 21 words out over SPI in C?
>>
>> I need to use a PIC 16c74 to program a National Semiconductor LMX2306
>> synthesizer. To program this device, I need to send out 3 21 bit words
>> over
>> the SPI bus. I am using a Hi-Tech C compiler. Does anybody know a simple
>> way to do this. A pointing to some sample code would be greatly
>> appreciated. I have been looking for a long time, but have not had much
>> luck finding what I need.
>>
>> TIA,
>> Ed
>>
>>
>The internal SPI is based on 8 bit words, as your requirement is not a
>multiple of 8 you will have to use software SPI (bit bashing).  
Not necessarily - you could probably just pad the data to 24 bits, you
just need to get the alignment right - the extra bits will just fall
out the end of the target's internal shift-register

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
"[PIC]:" PIC only "[EE]:" engineering "[OT]:" off topic "[AD]:" ad's

2000\08\30@083016 by Michael Rigby-Jones

flavicon
face
{Quote hidden}

I did think about this briefly, but this is exactly the sort of thing that
manufacturers don't specify in their datasheets.  It'd probably have to be a
"suck it and see" type of thing.

Mike

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
"[PIC]:" PIC only "[EE]:" engineering "[OT]:" off topic "[AD]:" ad's

More... (looser matching)
- Last day of these posts
- In 2000 , 2001 only
- Today
- New search...