How do i make a UART <-> SPI converter?

I have a bluetooth adapter that requires a SPI to be configured.
I tried making one that used a parallel port, and it didn’t work.
Tried connecting the adapter via it’s USB pins, but it’s firmware doesn’t support USB.

So i need a serial RS-232/TTL SPI adapter.
How would i go about making one?

I don’t care if it connects via RS-232 directly to a PC, or if it uses a RS-232 to TTL converter.

I’m searching online, but i’m having trouble finding schematics.

I want to try to keep it limited to common components, resistors, diodes, transistors.
IE no custom IC’s.

Though if you guys know a way to use the atom pro/ atom nano as a converter, please feel free to write a program for it, then give me the Pin#'s for it all.

IE for atom pro,
P14 -> TTL TX
P15 -> TTL RX
something -> SPI MISO

what ever, this stuff is over my head.

Hello, Fallentine.
Even a Nano can take in serial through its USB-programmer adapter and then bitbang SPI out to other pins.
The SHIFTIN and SHIFTOUT commands are what you want. Open Studio and start up the HELP manual and study those. Try writing some code and let us know how it goes. Someone here may have done what you want already, so better responses may happen yet.
kenjj

I just don’t know enough about SPI, or programming in general to make a RS-232 to SPI converter.
I don’t even know where to start.
The example in the Studio manual is specific to a PS2 game controller. And doesn’t make sense to me how to use this.

My limitations in programming are quite literally, if/then/else, and even then, i suck at those.

Hi, I have not done a true SPI on the Atom Pros for awhile. I did experiment with writing a more true SPI implementation for the PS2 that was bit bang. I have not tried using the using the underlying hardware for this.

I believe the hardware serial port on the BAP28 can be configured to do SPI by setting it up to synchronous simultaneous transmit/receive, which would probably work for SPI. The problem is that probably can not do this in basic. That is one would need to setup their own interrupt handler and setup the appropriate registers. It may not be hard, but I have not done so. Without some hardware it would be hard to test.
On the Bap28 I think you would use pins:
13 - Clock
14 - RXD (or in SPI terms - MISO)
15 - TXD (MOSI)

Kurt

I was thinking of using the atom nano 18 for this. Aton Pro is fine too, I can always try converting the code between them.
My thoughts for using the Nano 18, were because of it’s small package, i could make a board just for this… pop the nano18 in, do my programming, then pop it out and use the nano for something else. The atom pro being PCB/SMD based, is a little more fragile to be moved around.
The nano 18 supposed to support 3wire SPI. So it should work fine.
I could probably just leave CSB NC, or pull it down or something.

I’m not trying to use the atom pro/nano as a master, or spi programmer, just a converter, i know this can be done with many a PIC chips.
Just what ever i send to the serial port, goes to the SPI. I’d want the Atom to be as transparent as possible.

It’s to configure/program a bluetooth uart adapter.
The software allows for serial or parallel and a few other types of connections.

It’s not the connecting it that i have problems with, i can connect wires to pins.
It’s the programming. I have no clue how to make MISO -> RX, and TX-> MOSI,

[code]
MISO var byte
MOSI var byte

main
shiftin p2,blah [MISO]
serout p1,blah [MISO]

serin P0, blah, [MOSI]
shiftout p3,blah, [MOSI]
goto main[/code]
blah = parameters, which i wouldn’t know what to set.
I doubt it would be something simple like that. Like i said, i got no clue where to start.

Though i’m sure someone has done it before. It’s for a CSR Bluecore 4 based bluetooth adapter if that helps.

If you guys do the programming, just comment in it so i can figure out what you guys did, so i can learn from it. Unrelated examples like the PS2 controller are just no good to me.

Good Luck with this project.

As I have none of the devices like any nanos, I will not be much help here. I did see from the pic data sheet that it does have decent support for SPI…

Kurt

You might re-think the task first.

Why a CSR Bluecore 4 based bluetooth adapter? There are standard Bluetooth adapters that work with 232, see the Sparkfun units mentioned on the forum.

Alan KM6VV

It’s a bluetooth UART adapter with TTL serial lines.
It shows up when connected to a PC as a virtual serial port.
It just happens to use the CSR bluecore chipset, which is common with many bluetooth uart adapters.

If i can reprogram it, then i could upgrade it with a command configurable firmware.

It uses the same chipset as this
sparkfun.com/commerce/produc … ts_id=9913

Because of the outdated firmware on my bluetooth adapter, the only way to reconfigure it, is via an SPI link.
The only problem i have with this adapter, is it’s slow, it’s limited to 9600baud.
Which isn’t a hardware limitation, it’s just what’s set in the firmware.
If i can access the firmware, i can increase the baud to what ever i want, i’ll probably choose 28.8k or 38.4k
Either of which would be a major improvement over 9600 baud.

Also, it’s limited to slave mode as is, if i can access the firmware (i have the software but not the hardware) then i can set it to master mode and have it connect to another bluetooth uart module. A cheaper alternative to xbee. At least for now.

OK, I get it.

Every time I’ve done an SPI interface (PIC, ARM), I’ve needed longer words, and had to resort to bit-banging, in C.

That sounds like a lot of work to use the USB converter.

Sparkfun has the bitwacker, USB done with a PIC. SPI code could be written for it. MicroChip C (demo) is free for it. Sample USB code already written. Inexpensive.

Somebody probably has a USB to SPI converter.

Alan KM6VV

I’m going to rebuild my parallel programmer later today and try that again.
Right now though i gotta leave for work.

I just want to use
Serial to TTL converter -> Basic atom -> bluetooth.
I didn’t think using the aton as an SPI converter would have been such a complicated process.
I just assumed it was code that someone with the know-how had already written, or could write in 5 minutes.

My boyfriend figured out the problem after i left for work.
I was using a schemtic to build a parallel spi programmer from the sparkfun forums, but they didn’t mention of the parallel port was male or female, so i guessed based off this one.
http://www.cutedigi.com/images/Bluetooth-programmer.jpg

However my BF noticed it wasn’t right, and when i got home, told me the numbers were wrong and i was using the wrong port…

Now it works, and sure enough my crappy bluetooth uart adapter, just became 10x less crappy.
It took a simple minded guy, to find the simple solution to my problem.

The female port i was using, had it’s numbers reversed.
1: i should have been using the male port.

He was military and was trained to notice the tiniest of details.
forum.sparkfun.com/viewtopic.php?p=91380#p91380

Notice on the second schematic, the blue/black one.
Right under the port it says M25.
Something i completely overlooked.

And the numbers were backwords. I got the female parallel port off a very old laptop motherboard.
Where when facing at it, pin 1, is at the top left corner of the plug. Same as the male plug.
Which would connect to pin 13 on the male plug.
So when i saw the schematic, and the matching pin numbers, i assumed the schematic was using the female port.

My BF not only noticed the M25, but also noticed when comparing to another Female parallel plug, that the numbers were reversed.
I tried taking a picture to show you, but my camera doesn’t zoom in/focus close enough, plus it’s hard to see the numbers even with the naked eye.
The ports maker is Suyin though. Came off a compac armada m300.

So i got it to work by clipping the cable of a M-F parallel extension and used the male end. Works fine now.

Serial ports have pins that stick out, DB9 and DB25 alike. Parallel ports have 25 pin sockets instead. :stuck_out_tongue: