Wednesday, August 25, 2010

Aug.25 Timer Counter

Next Step: See exactly what code examples use
and understand what eCos wants to do for an application.

Following are notes / summary of my understanding of ARM7 Timer Counters from:

Color code: HighLevel; Register; Bit

TCs can be pgmd to:
  1. freq measurement
  2. **event counting (like lms motor tacho count)
  3. interval measurement
  4. pulse generation
  5. delay timing
  6. pulse width modulation 
  7. interrupt generation
Each channel has:
  • 3 external clk inputs=
  • 5 internal clk inputs= TIMER_CLOCK1-5; MCK/2 8 31 1128 1024
  • 2 multi-purpose i/o signals=
  • 1 internal interrupt signal = 33-2 Channel signal
  • (can be pgmd to generate processor interrupts
with
2 Operating Modes= DS p.444 / p.2 ApplNote 
  • Capture Mode  (measurement on signals) 
    • TIOA always output
    • TIOB 
      • usually output
      • can be selected as external trigger
  • Waveform Mode (wave generation)    
    • WAVE bit (=?) in TCx_CMR 
Triggers
3 common to both modes:
  • Software
    • set SWTRG bit in TCx_CCR
  • SYNC signal asserted. 
    • Asserted same time for all 3 channels 
      • "by writing TC_BCR (block cntl) with SYNC set(?)"
  • Compare RC Trigger
    • triggers "when counter value matches the RC value if CPCTRG is set in TCx_CMR
    •  (Does this relate to lms Schmitt trigger?)
1 external trigger (per channel)
  • in Capture Mode:
    • selected via TIOA and TIOB
  • in Waveform Mode:
    • Signals that can be programmed on
      •  TIOB
      •  XC0, XC1, XC2
    • External event triggered by setting ENETRG in TCxCMR
    • *Duration of pulses must be longer than the system clock (MCK) to be detected.

Clock Source

Timer Interrupt Generation

Tuesday, August 24, 2010

Aug.23 Interrupt never invoked?

Why is interrupt not called? 

Easiest to correct:
  • priority is too low
Since not comfortable with what eCos does and what is left to do likely...
Either:
eCos call to isr (interrupt service routine) 
  • match documentation?
  • match the structure of i2c working interrupt call
or
Commands to ARM7 to allow the interrupt are not fully correct.
  • check documentation
  • compare to examples of working code
  • via debugger check memory is really what expect

Monday, August 23, 2010

Aug.23 arm-elf-insight use

Revisiting /redocumenting debugging with arm-elf-insight because:
cygwin doesn't keep history between sessions anymore on lab PC, and found early debug description in March is missing details, as well understanding the process better now.
 
Created simple script, so don't have to remember a long path name to forte:

lmsdb.sh:
cd /cygdrive/d/AA_local/eclipseWork/forte_lms_neu/bin/lms/src
arm-elf-insight /cygdrive/d/AA_local/eclipseWork/forte_lms_neu/bin/lms/src/forte

0. flash lms with fw code updates (flash.bat or Sam-ba)
1. start openocd.bat 
in cygwin:
2. when lms is initialized (blinking led stopped), start arm-elf-insight using
./lmsdb.sh
3. In arm-elf-insight:
  • connect to target 
    • remote tcp with port 3333    (for Raven JTAG != 3333 for example: 8888)
  • in (view) console:
    • monitor halt
    • monitor reset
  • select (view) breakpoints
    • 1 breakpoint only if want to step
    • 2 breakpoints max.
    • for Raven montitor set hbreak 0xaaaaaa
      • where 0xaaaaaa is address from breakpoint window
4. continue
5. start usb connection
6. start application and wait for the breakpoint to be reached


Miscellaneous Notes:







    Sunday, August 22, 2010

    Aug.22 eCos Configuration

    Open eCos LMS topics:
    topics may be added

    Aug.22 eCos Interrupts and Motor

    Lego FW (in c) and Lejos FW (in c+asm) both have a minimum O/S and set-up interrupts themselves. nxtOSEK uses Lejos drivers in c and interrupt calls in asm.

    eCos provides interrupt support calls, so an interrupt call is done by the driver code, but eCos creates/releases and attaches/detaches interrupts.

    References:
    • eCos Reference pp.83-88 especially p.84
    • eCos Book -Sec. 3.2.3 pp.64-78  example p.69
    • in eCos code:  i2c_at91sam7sxxx.c (i2c driver) and platform_i2c.c (optional lego HW driver

    Tacho Counting via Interrupts:

    Ver.1: using Timer TC1: 
    • Interrupt when the motor goes from low to high.
    • Number of interrupts is part of the angle used
    Ver. 2: Interrupt when
    Topic 2: eCos configuration questions
    Tests:
    1. An interrupt occurs
    2. Get Tacho count

    Open Question:
    Should both an option using TCxs and not using in them be available?
    What needs to be faster Motor Tacho counting or Ultrasound sensor reading (US)?
    Can a mixture be used if the # of sensors and motors is known?

    Thursday, August 12, 2010

    Aug. 12 Motor Turn Tests

    How the motor(s) react can help us understand what can be expected from Lego HW.
    (Test environments:  Lego Mindstorms (MS) SW; eCos LMS)
    (Later?: various Lejos pkgs; RobotC)


    Tests:
    When multiple motors are told to turn at the same time... 
    • Is there a delay so motors really start 1 after the other? (eCos LMS; Lego MS SW)
    • When motors are told turn a specific angle - how accurate is it? (Lego MS SW)
    • How do motor run when told to use a specific power % 
      • once
      • repeatly

    Power to the motors initialized via the eCos I2C driver works and sending % power works.
    Also using Forte basic Motor FB.


    For Tacho using Lego FW as a starting example. eCos requires some changes so can't be exactly same, but counting edge changes using TC1 counter for now on just 1 motor.

    Tried various turning tests of all 3 motors at same time to see if they really turn at the same rate.


    eCos LMS Forte FBs: 
    All 3 motors set to same rate, power command sent multiple times
       - motors turn at same rate
    All 3 motors set to same rate,  power command sent once
      - motors turn at different rates 
        Possibly motor given command first turns faster, but hard to tell, which one is faster.


    Lego Mindstorms SW 1.0 (w/ updates) with Firmware 1.29
    3 motors in parallel connection with brake 
     - turn at same rate
    3 motors selected in Motor block
    - Motor A turns slower; Changed connections - so it was certain.
    - Using 360 degrees or 1 Rotation switching motors - Motor A stops short of 1 Rotation.

    (To be added motor turning with Lejos)

    Now have an idea what to expect.


    Success is when counter changes. Until we change eCos setting to use PIT for something else, can't use for all 3 motors.



    Sunday, August 1, 2010

    Acroymns Used in this Blog

    • FB       = IEC61499 Function Block
    • FW      = firmware
    • LMS    = Lego Mindstorms (trademarks of Lego)
    • SW     = Software