Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

JasonS

Member Since 06 Aug 2011
Offline Last Active Jan 17 2012 05:58 PM
-----

Posts I've Made

In Topic: SimpleNGen 1.4

11 August 2011 - 08:44 PM

I will poke around as well, and see if I can find anything. I think there is a lot of utility in being able to time things running in native mode, instead of strictly running at "max speed".


Sorry to self-reply, but I may have found something useful - assuming that my understanding of SimpleNGen and wanderings through .NETMF have lead me in the correct direction.

My understanding of SimpleNGen is that it is generating opcodes for the processor, sticking them into an array, and then moving the IP to the beginning of that array when called. So, I would assume then that what you would need for timing is some sort of delay instruction block which your compiler could generate based on some function call which you compiled away.

I browsed through the .NETMF source (Specifically, starting at the new OneWire implementation - since I knew it required sub ms timings). It made a series of calls (usDelay in the OneWire library), which eventually ended up at AT91_TIME_Driver::Sleep_uSec() in the .NETMF code for the AT91 hardware (I assumed that this is the correct hardware for NetDuino).

This method is in the .NETMF 4.2 codebase at: client_v4_2_comm/DeviceCode/Targets/Native/AT91/DeviceCode/AT91_TIME/AT91_TIME.cpp

The code is here:

void __section(SectionForFlashOperations) AT91_TIME_Driver::Sleep_uSec( UINT32 uSec )
{
    GLOBAL_LOCK(irq);

    UINT32 value   = AT91_TIMER_Driver::ReadCounter( AT91_TIMER_Driver::c_SystemTimer );
    UINT32 maxDiff  = CPU_MicrosecondsToTicks( uSec );      // The free-running timer clocks at a constant 3.25 MHz

    if(maxDiff <= AT91_SLEEP_USEC_FIXED_OVERHEAD_CLOCKS) maxDiff  = AT91_SLEEP_USEC_FIXED_OVERHEAD_CLOCKS;
    else                                                 maxDiff -= AT91_SLEEP_USEC_FIXED_OVERHEAD_CLOCKS;

    while((AT91_TIMER_Driver::ReadCounter( AT91_TIMER_Driver::c_SystemTimer ) - value) <= maxDiff);
}

Actually translating this into something directly useful to SimpleNGen is unfortunately beyond my knowledge of this hardware, firmware or memory layout. I am happy to break this into some slightly more useful code, if that is helpful, with things like actual memory addresses and constants instead of names - let me know. This is as far as I could get with notepad and grep on my work machine - pulling this all into an actual IDE will make it easier.

Hope this is generally the right direction!

--Jason

In Topic: SimpleNGen 1.4

08 August 2011 - 03:39 AM

Jason--are there NETMF 4.2 features you need, or can you use Corey's NETMF 4.1-based version in the meantime?


4.1 Is fine for me - my understanding was that Corey's 4.1-based version is for the base Netduino only - unfortunately, I only have a few of the Pro - Ethernet is important for my project. Is that not the case?

I wish I knew the answer to this. Unfortunately I am not an expert in the firmware. I had previously asked if anyone could help by pointing me to or creating sample C++ code that I could then adapt to SimpleNGen style, but I have not any luck in this area.


I will poke around as well, and see if I can find anything. I think there is a lot of utility in being able to time things running in native mode, instead of strictly running at "max speed".

Just out of curiosity, are you looking for something like the modulated PWM ?


Yes! That is exactly what I am trying to implement (the long way around) - I was going to use 2 pins ANDed together, the 38kHZ PWM and a second pin with the data. This requires me to drive the second PIN faster than I can directly on the netduino. I have voted for it on codeplex.

Thanks!

In Topic: SimpleNGen 1.4

06 August 2011 - 08:40 PM

I have just gotten into NetDuino, and was looking for some way to do atleast a small amount of high speed work in a larger project (specifically, I need high speed for sending IR signals for controlling various consumer electronics). This project looks terrific, and almost exactly what I need (great job Corey!). In reading through this, it appears that I need to wait for the 4.2 build with the appropriate items included, so I am also curious as to the timing on this. One thing that I need to do, which I have not yet seen an example of, or a method for in browsing through the SimpleNGen compiler code, is access to time/timers/sleeps/etc. The protocols I am interested in are time based, with no shared clock - so for example I need to trigger a 38kHZ carrier signal (generated by a PWM) for ~600 microseconds. If the code is fast enough, I can generate the 38kHZ carrier without the PWM which would allow me to use only one pin, but either way I need to manage timing it. Is there some mechanism for that in SimpleNGen? Thanks, Jason

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.