Hopeless and Lost

Comments

5 comments

  • Avatar
    Andre LaMothe

    Adam,

    I feel your pain. Modern ARM processors take a lot of work and learning curve to get working. This can mean hours, days, or weeks depending on the toolchain and vendor. That said, I have evaluated every tool for ARM development, and for price and ease of use and modern abilities rowley is the best IMO. That said, its just a tool and not going to help you build apps out of the box since its not one of the primary supported tools by ST, and all the examples don't work out of the box. You have to do some work.

    But, figuring it all out is overwhelming, its not hard ironically, you just don't know what you don't know so you don't know where to begin? Does that sound accurate?

    I have worked with every ARM processor and every tool, and I swear its like you have to be a detective to figure it all out. Then when you do (I take notes the entire time of course). I sit and think, this is WAY too complicated, 1% of people are going to figure this out, that's why so many start with arduino, but this is like shooting yourself in your foot since you still have no clue how to set up a REAL embedded work flow.

    Anyway, I have working with ST ARM cortex's for about 8 years -- I would be happy to get on skype and talk you thru your questions.

    Email me at ceo@nurve.net and we can talk about it --

    One good thing -- SPI is relatively easy compared to I2C which is a nightmare on ST hardware -- once you have the drivers working, great, but getting them working is ALWAYS a challenge.

    But, the good news is ST is probably the most widely used Cortex line and there are countless website with information, people writing drivers, blogs, etc. and you just read them all, and with a lot of work, it all starts to become clear :) You find a little tidbit on one blog, some app note that has another fact, an example program from the discovery demos etc. that's how you have to do it --

    Now, some vendors are easier to get working -- like TIs MSP432 Cortex for example, it comes with a free tool with examples that all work, so you have to do less digging, Silicon Labs is the same, Atmel to some degree, but their new tool is HORRIBLE and slow. But, when you use a 3rd party tool as you have to with ST, then if they don't have all the examples baked in then its a challenge.

    But, the good news is once you get it working, you never need to deal with it again... and just have your driver code, your tool setup, etc. and that's it --

    Andre'

     

    0
    Comment actions Permalink
  • Avatar
    Adam Thompson

    Thanks Andrè,

    I think you are correct in your assessment, using pic and atmel is easy and everything works well.  I have started reading the rowley crossworks reference again and it is slowly sinking in how the toolchain operates.  I have no problems with the ST data sheet being a former hardware eng but just getting bits to set to configure the SPI is proving challenging. Given I know which bits to set and I used to be able to C code for simpler platforms I expected to at least get this far.

    Anyway I'll continue to keep reading and learning to get over the initial learning curve. I appreciate your offer for Skype, I'll give it a few more sit down sessions and if I'm still having basic issues I'll take you up on that offer.

    I do have question in which you can probably answer easily. With the PIC environment setting registers was done buy writing the entire word to them. Is this the done method for ARM product as I note the include file has every bit for the control registers defined? Should I be using code like

    SPI1->CR1 &= ~(SPI_CR1_BIDIMODE | SPI_CR1_RXONLY);
    SPI1->CR1 |= (SPI_CR1_BIDIOE);

    to set and clear the bits required? This is code is not working anyway?

    Is there a reference anywhere as to the tidy way to approach or code control bits?

    Thanks

    Adam

    0
    Comment actions Permalink
  • Avatar
    Andre LaMothe

    Yes, bits are bits -- you can do a read write modify, write the whole thing at once. And ARM processors have "bit banding" which if you aren't familiar is a method of mapping n bits in a word to n words in memory, they aren't really there, but just games played with the huge address space to help with the age old RWM issue you allude to above. So, you can use that as well.

    https://www.youtube.com/watch?v=cQ2-hS7-v9Q

    But, my advice is to look at the "Discovery Board" demos for the Cortex M0. There are good examples of SPI there -- and if you still have trouble, I can give you a working SPI driver I wrote on top of the ST SPL.

    The thing to remember is the hardware is quirky on STs, so sometimes things don't do what they are supposed to and the ONLY way to get code to work is to SEE a working example from ST, and you are like EUREKA, he is setting x before y, and the ORDER of this makes a difference.

    I bump into weird things like that all the time.

    On Atmel, and Microchip processors, I can actually write a driver with nothing but the data sheet, but with ST hardware, this isn't the case, I always find silicon bugs, exceptions, etc. and sometimes they are actually in the silicon errata, but seriously who is going to hunt down every entry and read it -- finally, ST is french, I am french, and their docs SUCK! They have frenchman writing in English, or french, then translated to English, I am not sure, but its horrible, reads like "yoda" talking, drives me NUTS :)

    Andre'

     

     

    0
    Comment actions Permalink
  • Avatar
    Adam Thompson

    Ha yes does remind me a bit of yoda.  I watched the video, and all of his others, that you attached and it helped a lot.  I am making headway.  My issue was that I had not enabled the SPI clock in the RCC control registers. This is where I got caught with the difference between simple 8-bit architecture and more complex 32-bit types. The interaction between control registers and busses is configureable vs no configuration required.

    I took your advice and searched for an example which is how I worked out what the problem was. I am now beginning to understand the complexities of the system.  I guess i'm making my way up that steep learning curve. 

    Thank you Andrè your help has been invaluable.

    Adam

    0
    Comment actions Permalink
  • Avatar
    Andre LaMothe

    Good, just remember for everything you need to:

     

    1. Enable clocks.

    2. Enable GPIOs.

    3. Enable alternate function for said GPIOs.

    4. And if you are doing interrupts, this gets tricky, you have to enable interrupts for the peripheral, but this doesn't call interrupts, then you have to enable the actual interrupt to be called, then finally, you have to enable global interrupts :) And then you need to use the correct name for the interrupt which is in the one of the files, which is in the system file, with a "weak" binding, so you can overide it.

    Finally, I suggest at first, doing everything in a SINGLE file, or 2 at most a .c and .h or .cpp and .h. It just makes it easier since you are going to juggle a LOT of files hunting for things all the time. I have 20-50 files open at once, so I can look at headers, cmsis stuff, system and driver files, a lot to keep in mind at once.

    Anyway, good luck -- and I have used all the ST processors from M0 to M7 (which I am working with now) and have built custom PCBs and single board computers and products with them for many years, so I have the hardware setup down as well, when you cross that bridge...

    Andre'

     

     

    0
    Comment actions Permalink

Please sign in to leave a comment.