cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4 MCU

ThLe_297461
New Contributor II

 Hello folks,

   

 

   

I try to build a little terminal with the rc522 rfid reader chip ( on a tiny module from ebay ) and a OLED Display ( SSD1306 also SPI bus but in UDB mode because no chip select wire ) and of course the MIGHTY PSOC 4 ^.^

   

My problem:

   

I have a tiny Arduino due which works as expected. RFID reader hooked up OLED hooked up, Software written and it works.

   

So i have a definite working Reader and Display.

   

I hooked up the Display to the PSOC and started to write the Software to control it. Long Story many failures but finaly it works now. Also i got it managed to work with some GFX functions like circles Sprites and and and ( also a little Font ).

   

But the reader refuses to work. I even dont know if the communication works as expected because in the rx buffer are always values which are not expected. 0xE0 mostly. 

   

Has anybody managed to get this reader working with a SPI_SCB component ???

   

I make a try with good old static BitBanging but mhm I dont know what happens.

0 Likes
11 Replies
HeLi_263931
Honored Contributor II

Typical errors regarding SPI: each write is also a read, so it produces an entry in the RX FIFO. Also, you need to wait for the SPI transfer to finish before you read the Rx FIFO. And when the SPI clock is fast enough, you might not fill the TX buffer fast enough so it disabled the SELECT signal inside of a transmission.

   

Best is to check the signal lines with a logic analyzer or a scope.

0 Likes
ThLe_297461
New Contributor II

 Okay about that im aware.

   


   

I connected the reader without the chip select to the SCB Block. I control the CS pin seperate in code.

   


   

So i pull the CS low ( Active LOW ) then i make the TX WRITE wait until TX finished and then i Release CS back to HIGH ( CS_Write(1))

   

They do it the same in the Arduino Source.

   

I found also in a different post a Sniped for Readback the Value directly while sending but this also dont work as expected.

   

Tomorrow Ill walk over to the ETHZ ( University here ) and ask in the Laboratory for a hint with the Logic Analyser.

   

I think ill build myself a tiny one to check it. I got a nice Sourcecode for a PSOC5 Variant with included Scope from Someone AKA hlipka Maybe i get it only as LOGIC ANALYSER working. with the SSD1306 it would be awesome. little scale but AWESOME. Ah and the code is well readable.

   

 

   

 

   

Ill post it if i have further news.

0 Likes
HeLi_263931
Honored Contributor II
        I think I really need to port that project over to the PSoC5LP and make sure it runs there. Making the display code easily to change might also be helpful...   
One note: since it samples with at most 500kHz, reduce the SPI clock in your project to about 100kHz to be able to use it.   
0 Likes
ETRO_SSN583
Esteemed Contributor

As an aside a cheap but very good logic analyzer, I have 2 of them,

   

they work great.

   

 

   

www.ebay.com/itm/New-USB-Logic-Analyzer-Device-Set-USB-Cable-24MHz-8CH-24MHz-for-ARM-FPGA-/111540669...

   

 

   

www.saleae.com/downloads

   

 

   

Regards, Dana.

0 Likes
rola_264706
Honored Contributor II

On the logic analyzer does it have software or do you need to download one of the programs from the site on the next line from the web posting?

0 Likes
ETRO_SSN583
Esteemed Contributor

Yes, you have to download the software from the second link.

   

 

   

Regards, Dana.

0 Likes
ThLe_297461
New Contributor II

 reducing the speed did the trick. i saw on the scope also a weak connection on the MOSI wire ^.^ could happen. even it alwas read 0 ohms on the meter ?.?  okay now i get the status messages from the rc522. When i transfered all the Libraries to the PSOC Ill post it back here or on my page and a Link here. I can tell You. THIS IS FREAKIN AWESOME. ^.^

   

 

   

Ah @hli are You hlipka ??

0 Likes
HeLi_263931
Honored Contributor II

@lexarion: Yes, we are the same person

   

Glad you got it working (even though my speed reduction tip was aimed at using my Logic Analyzer project, not at your problem ...)

0 Likes
ThLe_297461
New Contributor II

 Nice. Ill have a look what the max speed is which is supported by the rc522 but im glad that this is working.

   

One question. I only need the logic analyser part of your firmware which parts are they ?? Or where should i look in ? Because all is wonderfull divided into seperate parts and so there are many different files.

0 Likes
HeLi_263931
Honored Contributor II

I would just keep the analog stuff in there, it doesn't hurt. Maybe its not obvious, but you can use it with a client for the openlogic sniffer (Jawi OLS is the best one available right now) too, instead of the GLCD.

   

If you really want to create a LA out of it: start with ripping out the SAR ADCs, their DAM and their input handling (the PGAs). Then look at the triggers. From there you need to clean the source code from all unreferenced stuff (most of it should be in scope.c/.h). Next would be DMA.c, and from there you will see that the display code in main.c needs to be touched. Also look at the menu code in handler_local.c to remove all the analog setup stuff. When you do that, you can probably increase the frequency options since the ports can run faster than the ADCs.

   

As I said, its easier to keep it in there 🙂

0 Likes
Anonymous
Not applicable

@lexarion - did you ever build a Psoc lib for the MFRC522? I'm a psoc newbie and trying to port over some MFRC522 code to Cypress devkit. Or if you got the reader working I would love to take a peek at your code kind sir 🙂

0 Likes