PDA

View Full Version : Teensy 3.1 Changes To Green PCB



Paul
01-23-2014, 09:04 PM
PJRC is changing Teensy 3.1 to green solder mask.

http://www.pjrc.com/store/teensy31.jpg

Since launching Teensy 3.0 on Kickstarter in late 2012, we started using black solder mask. It looked different, which seemed like a great idea at the time.

Over the last year and a half of making Teensy 3.0 and 3.1, we've been working on improving the quality and production yield. With any PCB, a small percentage fail. We test every Teensy throughly, so any shorts or opens are detected. The bad ones are saved for diagnosis and then we just toss them. (no, do not ask if we'll sell the bad boards at surplus prices, because we won't ever do that)

It turned out some of the failures could be traced back to the black solder mask. What seemed like it ought to be the same, just a different color, in fact isn't the same at all. The black material just doesn't have quite a high a resolution as the green. I was very surprised to learn this, but it's true.

So we're changing Teensy 3.1 back to green. The other PJRC products with black solder mask will also switch back to green as their stock runs out and we make more boards.

stevech
01-24-2014, 12:03 AM
How 'bout White? Yellow?
(just kidding)

Headroom
01-24-2014, 12:42 AM
You can get white or yellow. However, I recently read an article describing problems with white and the coating flaking off. A problem that was attributed to the pigments necessary to achieve the white color.
I guess there's a reason that I yet have to find another color than green in any consumer or industrial device I've ever taken apart.

stevech
01-24-2014, 03:13 AM
OK. Make it Red.

Markus_L811
01-24-2014, 07:40 AM
I will vote for crystal.

Btw I like the black one's but as my mother say's about the color of cars, it has to work apart this the color stays on the 2nd place and no I won't buy a car in pink. And at least inside the car you won't see the color.

neslekkim
01-25-2014, 02:46 PM
Black and white also have the problem that it is difficult to see the traces under it. Green and read are better.

jmccommons11
01-25-2014, 02:52 PM
So, make it clear.
I LIKE being able to see the PCB!

PaulStoffregen
01-25-2014, 04:56 PM
Clear would be awesome.

But Teensy 3.1 is a 4 layer board. Layer #2 (the one just underneath all the components) is a ground plane. That layer is opaque, except near the edges and between the pins where a via blocks the plane from reaching. In the photo, you can see board is much lighter near the edges, since this photo was taken on a light table with some light shining through the PCB.

MuShoo
01-26-2014, 04:49 AM
Wouldn't that make a clear board end up looking almost like raw copper? That might be kinda cool, too...

scswift
01-26-2014, 10:27 AM
I find this hard to believe. First, I haven't been able to find any reference to this being an issue. Where did you hear this? Second, motherboards and 3D cards and sound cards and all that fun stuff are way more densely populated than your boards and they're all kinds of crazy colors. If there were an issue with a particular color causing a significant increase in the failure rate, I kinda doubt we'd see any 3D accelerators or motherboards with black PCBs.

Are you sure the issue isn't just your PCB house? I mean, wouldn't any PCB house worth their salt be electrically testing the traces to make sure they're okay before they populate the boards, thus averting this issue? Could it be they're just doing a quick visual inspection and it's harder to see the traces on the black PCBs?

I use Gold Phoenix to manufacture my boards and their website says they do electrical testing on all boards with more than 2 layers.

[edit]

Actually I did find this one page just now which lists inks used for photo resist:
http://www.taiyoink.com.tw/en/products/index_01.html

It does list two different black inks, one with "excellent" and one with "good" performance. Perhaps your PCB house is using a poor quality ink? Still, I'd think they'd catch any bad boards with electrical testing.

scswift
01-26-2014, 10:42 AM
Also please don't go with clear. That looks so cheap. It's worse than green. :(



I guess there's a reason that I yet have to find another color than green in any consumer or industrial device I've ever taken apart.


Really? You've never seen those tan boards with no solder resist that they stick inside stoves and washing machines where they only have a few through hole components? And you've never looked inside a PC where the motherboard is blue, and the 3D card is black, and the IO expansion card is red?

I assume they use green inside most consumer devices because in the past it's been the least expensive. But anytime they expect the consumer to see the PCB, as when upgrading their PC, they use other colors because green looks cheap.

Headroom
01-26-2014, 01:04 PM
I've started taking electronics devices apart 35 years ago. Not sure what I was thinking when I wrote that I had not seen other colors. But that is actually somewhat beside the point really.

Based on previous posts it's clear that Paul's manufacturer of choice is local and within driving distance. For a small company such as Paul's that does not make 10000 thousands of boards a month, with limited resources in terms of personnel and finances and operating on a very small margin, that is a must. When problems occur you can react very fast without having a whole lot of product in your logistics chain that could potentially be bad. So there is not that much of a choice there.

When you have enough data and have identified the color of the solder mask as a problem that reduces yield it is just common sense to address that problem. Unless you can convince your manufacturer to use a better product for the solder mask, there are really only two more options. You can change the solder mask to something that has more reliable over the last 40 years (because back then everything was either green or reddish), or you select another manufacturer with the very high risk of having startup problems because of their different problem. But then, again, if you're operating on a small margin that does not allow for much room to play.

stevech
01-26-2014, 01:50 PM
well, I'll be happy with any color so long as it simplifies Paul's QA process!

PaulStoffregen
01-26-2014, 02:34 PM
Quite a few behind-the-scenes improvements have been made over the last several months.

I actually sent quite a bit of time looking into solder mask alternatives. There are a LOT of options if you're willing to pay more. But the last thing I want to do is raise the price of Teensy.

MichaelMeissner
01-26-2014, 02:54 PM
For me, the green pcb's will be useful, as I haven't yet ordered Teensy 3.1's, and the green vs. black pcbs should give me more of a clue of which target I'm going to. However, I suspect sooner or later, I will forget to change the processor type.

PaulStoffregen
01-26-2014, 03:18 PM
Teensy Loader parses your .elf file, if it exists in the same directory as the .hex file. The architecture (avr vs arm), stack starting address and a couple other symbols are used to figure out which processor you selected when building the code.

If the wrong board is connected, you'll get an error message explaining the mismatch. It won't load obviously incompatible code. Well, unless you delete the .elf file, in which case the .hex is blindly trusted and written onto your Teensy.

scswift
01-26-2014, 04:02 PM
Based on previous posts it's clear that Paul's manufacturer of choice is local and within driving distance. For a small company such as Paul's that does not make 10000 thousands of boards a month, with limited resources in terms of personnel and finances and operating on a very small margin, that is a must. When problems occur you can react very fast without having a whole lot of product in your logistics chain that could potentially be bad. So there is not that much of a choice there.

I designed a microcontroller of my own with a budget of around $22K. I spent 8 months working on it full time, and spent the last $9K I had on a run of 150 of them. I know what operating on a small margin is like.

I also know that it costs less than half as much to get boards made in China as it does in the US.

To give you an example, the assembly cost for those 150 boards was $500. In the US it cost me $750 to have another 50 assembled. And it was only that low because they gave me a deal after I told them I'd been using Gold Phoenix. When I later emailed another one of their representatives asking for a quote for another 50 boards the price for assembly had jumped to $1,600.

And lest there be any confusion... That's $1,600 for 50 boards, not 150. So you're looking at $3-$5K to have 150 boards assembled in the US versus $500 for the same in China.

If you're operating on a tight budget, and you have to choose between rapid turn times or saving 85% on assembly, it seems foolish to choose the faster turn time. A couple weeks delay is probably not going to make or break you, but spending thousands of dollars more for your product might.

MichaelMeissner
01-26-2014, 04:11 PM
Teensy Loader parses your .elf file, if it exists in the same directory as the .hex file. The architecture (avr vs arm), stack starting address and a couple other symbols are used to figure out which processor you selected when building the code.

If the wrong board is connected, you'll get an error message explaining the mismatch. It won't load obviously incompatible code. Well, unless you delete the .elf file, in which case the .hex is blindly trusted and written onto your Teensy.
I figured there were checks. It is good to know, I won't cause problems when I get to multiple teensy versions.

Parth Chauhan
01-27-2014, 04:50 AM
Hi Paul,

Can you please elaborate a more by what you mean as resolution that is available in case of green PCB and not black PCB ?

I basically want to know the difference that will be observed between the Green and Black PCB , Is it the visiblity of tracks or the layout or something related to electronics. Request you to please explain this with an example.

Thank you.

scswift
01-27-2014, 10:05 AM
Parth:
The only difference between the two that you'd notice is the color. He's making the switch because he's getting too many PCBs back from the manufacturer that have broken traces or shorts, and he believes the color of the solder mask has something to do with this.

I'm not sure I understand how that could be the case though. Isn't the solder mask applied after they etch the board, like a stencil? If so, unless the problem were solder mask overlapping pads, which seems extremely unlikely, I don't see how the resolution of the solder mask could affect the traces and result in PCBs that don't work.

PaulStoffregen
01-27-2014, 11:32 AM
Can you please elaborate a more by what you mean as resolution that is available in case of green PCB and not black PCB ?


I wish I knew. PCB fab vendors can be remarkably cagey when it comes to process details, especially when having to admit something isn't up to spec.



I basically want to know the difference that will be observed between the Green and Black PCB , Is it the visiblity of tracks or the layout or something related to electronics.


That too is a good question. I know a bit more on this, but again, this involves some interpretation from what a PCB assembly vendor is willing to admit. (Two different vendors here, the "PCB fab" vendor actually makes the circuit board, the "PCB assembly" vendor solders all the parts onto the board)

The solder mask is a non-conductive film applied over the entire PCB, except the pads where you're supposed to solder parts. Its main purpose is to prevent the solder from flowing down the traces, away from the pad. A secondary purpose is providing a very low surface adhesion to the molten solder, so if any solder does accidentally get incorrectly applied off the pads, it will tend to be pulled towards the pad. The solder adheres to the plated metal surface on the pad, and has very little "stick" to the surface with solder mask.

With the black solder mask, we were seeing defects in the mask material. Again, I don't have a good feel for the numbers (going back to the difficulty of getting vendors to be forthcoming with quality problems that expose problems in their process), but it's probably something like 1% to 5% of the boards had these issues, in varying degree. I also don't have really good info about what the defects really were, but some I saw appears to be missing solder mask, or perhaps really thin spots in random places. It's remarkably hard to know after the board is built.

The board can still be soldered and work perfectly, even without the solder mask.

By far the worst problem we saw was difficulty inspecting the boards. Our assembly vendor uses a camera system. I haven't personally used this system or even seen it in operation (they did offer to give me a demo, but the timing hasn't worked out... I'm extremely busy and I tend to work odd hours). So this is only based on what I've been told, so you're hearing it 3rd hand. Apparently the camera views the PCB from multiple angles and image recognition software analyzes the solder joints. The problem is only an ideally shaped solder joint passes. A perfectly fine solder joint that has the solder distributed differently, because some of it "escaped" onto the trace underneath (especially to the large center pad on the QFN chip) or down the trace away from the part, will "fail" on the camera inspection system. Then a real human needs to inspect the board.

The vast majority of the cost on Teensy comes from 2 places: the silicon and the PCB assembly (software development isn't counted in the cost per board). If anyone ever wonders how Sparkfun is so successful, consider they do all their own assembly work and they do very little software themselves! Their main cost is the silicon, and they can afford to pour a lot of money into website development, which clearly shows in the awesomeness of their site. PJRC operates on a very different, not nearly as profitable model, where most of my focus is on developing software. Teensy3 is a 4-layer board, which adds cost too, but not on the scale of the chip and assembly. Much of the reason we can make Teensy affordable is because I work pretty closely with a couple local PCB assembly vendors. These troubles with the solder mask were mostly about automated inspection.

In extreme cases, solder mask problems can lead to unconnected pins or even shorts. If the solder that was supposed to connect the pin all flows away because the connecting trace is exposed, it's possible to end up with an unconnected pin. But that's pretty rare. The pad and the pin are plated with metals that optimize solder adhesion, and the solder is already touching them. For an open to happen, this needs to coincide with some other problem, like the part wasn't placed accurately or the PCB wasn't perfectly flat, which just don't tend to happen. It's also possible to end up with shorts between the pins. But again, for that to happen there needs to be solder deposited between the pins, which ideally shouldn't happen if the stencil is correctly aligned when the solder paste is applied.

If any part of this sounds well researched, let me assure you that is only in hindsight. The reality of dealing with these manufacturability issue is far less certain. We would get a batch of boards in, or a partial batch if we were close to running out (even though they would run all the panels on the pick-and-place and reflow machine at once, they were struggling with inspection which limited the rate we'd get them), but often we'd test and package them as needed to ship orders. Soldering the pins to boards takes a lot of time, which is why we charge $3 more for the pins soldered, and it puts a limit on how quickly we can test and package a batch of incoming boards. That limits how fast we can get feedback to the PCB assembly vendor. The pain they suffered having to visually inspect so many boards is largely forgotten and turns into a sign of relief when we report that virtually all of them actually passed electrical testing here. Remember, they're not not always very forthcoming about limitations on their end, with much of the communication issues internally between their production people and their management, so inspection issues didn't become known to me until recently. On this side, Robin, Erin and I are highly focused on delivering good products, shipping orders fast and a huge number of day-to-day things that come with running a tiny 3-person company. Optimizing a production process, where only a tiny percentage of boards actually fail, well, just isn't as high a priority as a mountain of other stuff. Until mid-2013, to be honest, a lot of Arduino libraries still needed porting for Teensy 3.0, so I just wasn't able to focus on much else that wasn't extremely urgent. The easy answer is to just write off and discard the small number of bad boards. It's taken about 1 year and especially the last several months of working closely with our assembly vendor to really refine this process. On both sides, we've really increased our attention to optimizing the manufacturing process. The same happened years ago with Teensy 2.0 and Teensy++ 2.0. Most of this stuff is very mundane details you'll never see. Another upcoming change is a very small adjustment of the size of the center pad under the Mini54 chip, and perhaps to the 4 smaller cutouts in the stencil that put 70% solder paste coverage on that big pad. Usually these refinements are invisible details. Much to my surprise, one of the problems turned out to be black solder mask. The change to green is pretty easy to spot. ;)

PaulStoffregen
01-27-2014, 12:48 PM
I should also mention high quality solder mask is possible in different colors, from premium PCB vendors. They tend to have premium pricing.

Laen from OSH Park helped me approach a couple fabs he's used. They have excellent quality and could probably do black solder mask very well. They certainly can with purple. But their prices are much higher. Using them would have meant raising the price of a Teensy 3.1 to about $20.50 to $21.00.

Likewise, the silk screen printing resolution can also vary quite a bit. If you look at a Teensy 3.1 under a microscope, you can see the resolution of the white printing. The Arduino people have absolutely beautiful printing and solder mask on their boards from the last couple years.... I believe starting around the era of Uno R2. I have an original Uno that has silk screen similar to Teensy and most circuit boards. Obviously they've invested a lot of optimization in the aesthetics of their boards.

My goal has been to keep Teensy as affordable as possible and sustain as much software development effort as possible, which is obviously only possible due to the sale of Teensy boards. Making circuit boards with distinctive colors seems to be the norm in this market. A few people suggested this and it seemed like a great idea for PJRC to try, so we did it starting with the Kickstarter for Teensy 3.0. In hindsight, doing it well with ordinary low cost boards isn't easy. I certainly didn't know this in mid-2012. PJRC is going to stay with the mainstream green PCBs (once the remaining black ones are sold... I believe only the audio board and wiz820 adaptor are left) and hopefully we'll distinguish PJRC from the many other companies in this market with superior software and support rather than the color and other aesthetics of the circuit boards.

Pointy
01-27-2014, 03:58 PM
hopefully we'll distinguish PJRC from the many other companies in this market with superior software and support rather than the color and other aesthetics of the circuit boards.

Spot on Paul!

Functionality and software are far more important, at the end of the day most of these boards will probably end up inside some form of enclosure and won't be seen anyway.

I probably should know something about solder resist as my old man set up and ran a very successful PCB ink company for over 25 years. All I do know is that some colors were harder than others to get right, I think sometimes it was just the amount of pigment, rather than what pigment was used. It's kind of logical if you think about it, you might have to add twice as much white pigment as green to get a good color, twice as much powder added to the resin mix might make it more brittle or not stick as well.

Anyway, I couldn't care if the Teensy was sky blue pink with yellow polka dots, it's what it does that counts!.

Regards,

Les

buffington
01-27-2014, 04:32 PM
I recently received a green Teensy 3.1 and was confused for all of about 3 seconds. Once that was cleared up, I put the Teensy 3.1 to work and never thought about the color again (aside from now).

kam42
01-27-2014, 05:33 PM
Laen from OSH Park helped me approach a couple fabs he's used.

Any chance you could point us in their direction? Always interested in quality fabricators.

Parth Chauhan
01-28-2014, 04:32 AM
Hi Paul,
Thank you for the reply. I am not sure but yes, I do agree the problem is with the automated testing. I have some knowledge on Image processing and, I think that is where the problem lies with testing the black board. You see when we take the images of black board it is very diffcult to make out the tracks but the with green board it is very easy to spot the tracks and this is why it is easy to do automated testing with green board rather than black board and also track the short circuits and open circuits. Although I am not sure how does the PCB material affect the tracks.
I also do agree with you "Functionality and software are far more important". I mean when making a project no one is gonna look into the colour of the board that you used by that, I mean no one will be impressed with the colour of the board but a person like me would rather look into the efforts put and the output and ofcourse the functionality of it, rather than the packing.
So keep up the good work.
I am new to ARM myself though, I have done a lot in AVR. I would also request you to please update the "how-to tips" page. It seems to have all about AVR(like how to access DDRx and PORTx in AVR in C-language) and very less or almost nothing on ARM. I mean, I basically want to know how to access port in ARM. Is the architecture similar to AVR both being based on RISC architecture or There is some other way. Its very difficult to find this in the datasheet. Also please suggest some book like mazidi where, I can find all this as the datasheet is very less helpful.

kingforger
01-28-2014, 04:42 PM
Green is better anyway. I can follow the traces on the board much more easily. Black annoyed me because it was difficult to find them and cut them when I needed to do JTAG.

stevech
01-28-2014, 04:53 PM
Hi Paul,
Is the architecture similar to AVR both being based on RISC architecture .
Ports: The ARM/Teensy3s use the same conventions as AVR / Arduino: digital.write(pinNumber), etc. The SPI support at the library level is the same coding as for AVR, Paul has library code that makes it transparent. But, for example, there is a new library for SPI that exploits the FIFO based hardware in the Teensy 3. This example is typical.

I'd like to see some users organize to help write more on the Teensy 3 usage. Paul is generous to a fault with his time on this forum answering questions and add software sustaining/developing plus running a business must be all-consuming.

Headroom
01-28-2014, 10:01 PM
But, for example, there is a new library for SPI that exploits the FIFO based hardware in the Teensy 3.

Since Teensyduino 18 the "standard" SPI includes SPIFIFO . Well at least int includes:


#if defined(__arm__)
#include "SPIFIFO.h"
#ifdef HAS_SPIFIFO
#define USE_SPIFIFO
#endif
#endif

in W5100.cpp ;-)

Parth Chauhan
01-29-2014, 03:51 AM
Hi Stevech,
I am really interested in helping you and the Teensy community with the documentation but, I need some one to guide me as, I am very new ARM(By new, I mean, I can program teensy using the libraries compatible with arduino but beyond that, I am helpless). Please mail me on my mail ID(chauhanparth26@gmail.com) for any help with documentation. I have read the datasheet but, I am unaware of how to program ARM in C. I mean, I am fine with all the arduino libraries that PAUL has worked to make compatible with Teensy3.x but to extract more out of teensy3.x, we would require more libraries and in some cases more info on the IC than just Arduino compatible software/libraries because Teensy3.x is at hole another level, there is lot more that needs to extracted from this controller.

stevech
01-29-2014, 04:42 AM
ARM, AVR. The libraries do abstract the hardware so that the newbie can just follow example programs to learn, slowly modify these examples, then adding his/her own new code.

PaulStoffregen
01-29-2014, 10:42 AM
I can program teensy using the libraries compatible with arduino but beyond that, I am helpless).
.....
but, I am unaware of how to program ARM in C. I mean, I am fine with all the arduino libraries that PAUL has worked to make compatible with Teensy3.x but to extract more out of teensy3.x, we would require more libraries and in some cases more info on the IC than just Arduino compatible software/libraries because Teensy3.x is at hole another level, there is lot more that needs to extracted from this controller.

Arduino is really just C and C++ with a tiny bit of preprocessing and easy to use libraries.

As a first small step, I'd recommend using File > Preferences to turn on verbose info while compiling. Then you will see the actual gcc compiler commands Arduino is using.

Constantin
01-29-2014, 01:39 PM
As much as colored PCBs add 'cool factor', the first priority for the thing is to work in the first place.

Secondly, I can also understand why Paul would prefer to source his PCBs and assembly locally. It gives him better control of his supply chain, it shortens turn-around time, reduces WIP, and adds recourse in case something goes terribly wrong. Paul also has likely reached a scale where producing in the US is no longer as disadvantageous as it is for low volume production. US PCB manufacturers and assemblers by and large appear to have transitioned to a model where they either offer reasonable turnaround at very high prices (catering to commercial customers) or producing at scale. Hobbyists pretty much have to avail themselves to shoe-horned board sizes (pcb123, for example) or paying a premium to make a board with Laen, etc. to make it in the US.

Ditto for stencils. I can get a framed stainless steel stencil that's good for 0.5mm pin pitch for the same money that Pololu charges for a similarly-sized laser-cut mylar sheet. Both work... but the stainless stencil certainly is going to give me a much longer life than mylar... the only downside is that the mylar is available in different thicknesses - to accommodate fine or coarser pitches. Oh, and I suppose there is a theoretical possibility of adding new pad holes to the mylar sheet with an xacto knife if you only have a very minor board revision (i.e. add a single resistor) - but you can also solder those outliers by hand, if need be.

FWIW, I have been very happy with iteadstudio and Laen's services. My (comparatively crude) PCBs have come out fine in green, blue, red, and (in Laen's case) purple. I've chosen red as my base color simply because I like it. Were the color to lead to issues, then I'd switch back to green in a heartbeat. And I totally agree on steering clear of 'clear' boards. All you'd see on a board like that is the glassfibers encased inside. If you want to see through the board, you'd have to specify something like mylar (flexible Teensy!) at a high premium. I'm not sure 4-layer mylar is available either, nor whether I'd trust it to maintain all the connections despite being bent, etc.

Parth Chauhan
01-30-2014, 02:50 AM
"As a first small step, I'd recommend using File > Preferences to turn on verbose info while compiling. Then you will see the actual gcc compiler commands Arduino is using"

I always do that. I try a little more to explain what exactly, I want. Please consider the following programs:

In GCC for Led Blink:
#define F_CPU 160000000 // AVR clock frequency in Hz, used by util/delay.h
#include <avr/io.h>
#include <util/delay.h>

int main() {
DDRD |= (1<<DDD1); // set LED pin PD1 to output
while (1) {
PORTD |= (1<<PORTD1); // drive PD1 high
_delay_ms(1000); // delay 1010 ms
PORTD &= ~(1<<PORTD1); // drive PD1 low
_delay_ms(1000); // delay 1000 ms
}
}

Where in Arduino/Teensy Same code would be written as:

//Assuming Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

Now if you observe both the codes, I am am able to understand at the hardware level in the 1st code what excatly is happening(which DDR and PORT are changing) and more understanding on the processor and on compilation in GCC less space shall be required as compared to the 2nd Code.
But in the second code, I have no idea what is happening(I mean, I don't even know which port is being toggeled).
I am actually more accustomed to writing code in GCC and Arduino/teensy makes it very easy like when a person writes Serial.Begin(9600) he is not aware how many registeres(UCSRA,UCSSRB and UCSRC) are changed or why the number 9600 and not 9000. I love programming the way when, I am aware of everything. Its like, I know every nerve,part and heart of that processor and, I know how to control them .
Anyways for now, I think it shall be better that, I explore the libraries and when, I exhaust them then, I will switch to getting more into ARM getting to know the registers.
Just one more question "Can we get the assembly code or GCC code that is compiled from Arduino" , I mean From the 2nd code that, I wrote above can we get the 1st one or the assembly of the same. I basically want to understand what is happening at register level.

Thialf
02-06-2014, 02:58 PM
maybe your:
#define F_CPU 160000000 // AVR clock frequency in Hz, used by util/delay.h
has too many zeros ;-) Nice, a atmega with 160MHz

To get the assembler of an arduino-sketch, just do this:
http://rcarduino.blogspot.de/2012/09/how-to-view-arduino-assembly.html

Of course, arduino has some kind of an abstraction layer, with all its pros and cons.
And one pro is: You don't have such hardly readable values like 16000000, that could easily be wrong :D
But it's nice to have the ability to use all the registers directly. Imho are the manuals of the ARM-controllers quite usefull.

instrumentek
02-07-2014, 12:57 AM
I believe green is one of the most visible colors to the human eye. I am an avid shooter and they paint our indoor range green for this reason, also it is why green laser sights are a lot more visible then the red. The green boards seem to be the best for visibility on many levels.

PaulStoffregen
02-07-2014, 09:48 AM
Just one more question "Can we get the assembly code or GCC code that is compiled from Arduino" , I mean From the 2nd code that, I wrote above can we get the 1st one or the assembly of the same. I basically want to understand what is happening at register level.

Yes, you can get this code. In fact, if you've installed Teensyduino, you already have it. Just look inside Arduino, in hardware/teensy/cores/teensy3. On Macintosh, control-click on Arduino and "show package contents" to look inside. On Windows and Linux, Arduino is just ordinary directories and files.

The code is also available here:

https://github.com/PaulStoffregen/cores

Like with AVR, you'll need to refer to the manual that documents the registers. Here's the one for Teensy 3.1.

http://www.pjrc.com/teensy/K20P64M72SF1RM.pdf

The I/O registers are documented in chapter 49, starting on page 1331. Each port has 6 registers. Three are basically the same as the ones you're familiar with from AVR. The other 3 allow set, clear and toggle without having to read the current output state. In fact, I believe Atmel's newest XMEGA AVR chips have this same 6 register set.

One other register that is very different from AVR is the port config register. It's actually documented in chapter 11, starting on page 219. Every pin has its own 32 bit register that configures what that pin does. On 8 bit AVR, when you enable the UART, those pins are commandeered by the UART and no longer work with the 3 normal I/O. The SPI sort-of grabs control of the pins, except the DDR register still has some effect. Each peripheral has its own rules on AVR. On this Freescale chip, you explicitly control the function of every pin with these config registers. No pin automatically changes function when you enable some peripheral. You write to the config register for each pin to set exactly what it does. The pullup resistors, pin change interrupts and DMA requests and other pin specific features are also controlled here. The GPIO registers are considered to be just one of many peripherals that can control the pins, which is why this pin config stuff is in a different section than the GPIO registers.

If you really want to dig into the register level control of everything, you certainly can. All the code is published and everything in this chip is well documented. But some of these peripherals are dramatically more sophisticated than those found on AVR chips, with an incredible number of options and features.

One important feature that unfortunately isn't well documented in that manual is the ARM bitband addressing. It's mentioned in section 4.2.1. Currently it's only used in an Arduino macro compatibility layer I wrote. I do intend to use it more in future versions. There's plenty of great documentation on ARM's website, so I'm sure you'll find info on the bitband addressing if you use google. In fact, if you really want to get into knowing and understanding the very low-level details, you can find extremely detailed information about the ARM processor and its many subsystems that is far more descriptive than anything Atmel publishes for AVR. The main document you want is ARM code "DDI0403D". A quick google search can get you the PDF version.

duff
02-09-2014, 03:51 AM
One important feature that unfortunately isn't well documented in that manual is the ARM bitband addressing.


Hi Paul and All ;),

So a few beers into my night and was messing around with Bitbanding....., Question? when setting peripheral registers that are declared uint8_t, such as register LLWU_RST. Can I set their bits with this code actually borrowed from your avr_emulation.h:


#define BITBAND_ADDR(reg, bit) (((uint32_t)&(reg) - 0x40000000) * 32 + (bit) * 4 + 0x42000000)
#define BITBAND_U8(reg, bit) (*(uint8_t *)BITBAND_ADDR((reg), (bit)))


It seems to work for me, if delared as uint32_t, crash burn, uint8_t it works as usual. To me, single cycle writes should be the norm, so why is it not? and would the above example really be single cycle write?

freto
02-11-2014, 06:16 AM
It looks like the Teensy 3.1 is also available in purple at OshPark (http://store.oshpark.com/products/teensy-3-1)!
Is this a limited (for sure it will be collector value in a few years) edition?