This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ZStack Timers

Other Parts Discussed in Thread: CC2420, Z-STACK, CC2520, CC2430

I am trying to use the HAL timers, and the only one that allows me to put in a time value is HalTimerStart, which wants microseconds.  When I put in 10000 (for a 10 ms pulse) I get between a 4.7 & 5.3 ms pulse, and when I put on 20000, I still get the same thing.  How do you control the timer, and where can I find this documented?

Here is my call to HalTimerConfig:

  HalTimerConfig(HAL_TIMER_0, HAL_TIMER_MODE_CTC, HAL_TIMER_CHANNEL_SINGLE,
                 HAL_TIMER_CH_MODE_OUTPUT_COMPARE, FALSE, PinResetCallback);

Here is my call to HalTimerStart:

      HalTimerStart(HAL_TIMER_0, VentRotorMicroSec);

where VentRotorMicroSec is defined as either 10000 or 20000.

TIA,

anw

  • Which version of the Z-Stack are you using?  Is it targeting the MSP2618+CC2520 (or CC2420) or the CC243x device?

    The HAL Layer API functions should be defined in the Components\hal\target\<target device> directory in hal_timer.c for your reference.

  • It's targeting the CC2430.  I've looked through the HAL stuff, and what I was expecting was to find where

    memory-mapped registers were read and written.  For example, if I remember correctly (I'm not at my

    development machine), LED0 is port P1.1 and LED1 is port P1.0, or something like that, and port P1 is at

    memory location 0xDDF90.  I can't find where the control and data registers are written to control the LED.

    In fact, I can find no reference to the 0xDDF00 I/O memory block anywhere in the C code, and can't find

    any assembler code.

     

    The main reason, however, I was looking for this is because I want to use different peripherals to do other

    things and was looking for a model to follow.  For the LEDs, I really kludged something up, by just going into the HAL

    LED code and inserting P1_3 whereever P1_1 was, or something like that (again, sorry for the ambiguity,

    but I'm not at my dev system), and it actually worked, but I still have no idea what's going on "under

    the hood", or how to use a more complex device like an ADC, or how to use the other devices and the LEDs

    at the same time.

     

    Thanks for the response!

     

  • hephaestus said:

    I've looked through the HAL stuff, and what I was expecting was to find where memory-mapped registers were read and written.
    For example, if I remember correctly (I'm not at my development machine), LED0 is port P1.1 and LED1 is port P1.0, or something like that, and port P1 is at memory location 0xDDF90.
    I can't find where the control and data registers are written to control the LED.
    In fact, I can find no reference to the 0xDDF00 I/O memory block anywhere in the C code, and can't find any assembler code.


    The HAL code is written in an attempt to provide an abstraction layer from the physical hardware to allow for easier migration and porting.  I'm sure you know that, but as you discovered,
    it has the side effect of adding a layer of abstraction and sometimes can make it difficult to get down under the hood.  Rather than have someone perform a search-and-replace on the
    entire code base, the idea is to replace in one spot.  For the LED example, the spot for the CC2430 is Components\hal\target\CC2430BB\hal_board_cfg.h.  You will find macros (ie. #define)
    declared which translate calls made by Components\hal\target\CC2430BB\hal_led.c like HAL_TURN_OFF_LED1() into accesses to the registers (through more indirection).  In order to know how
    P1_0 translates to something physical, it depends on how IAR or KEIL have defined this in their CC2430.h header file.

    hephaestus said:

    The main reason, however, I was looking for this is because I want to use different peripherals to do other things and was looking for a model to follow.
    For the LEDs, I really kludged something up, by just going into the HAL LED code and inserting P1_3 whereever P1_1 was, or something like that (again,
    sorry for the ambiguity, but I'm not at my dev system), and it actually worked, but I still have no idea what's going on "under the hood", or how to use a
    more complex device like an ADC, or how to use the other devices and the LEDs at the same time.


    The LEDs are a simple example and as you indicated, can be kludged together relatively easily.  In the end, it is toggling a GPIO.  However, other functions like timers, uarts, etc. have more
    meaty drivers associated with them.  The Components\hal\target\<board> should be your guide in terms of mapping certain functionality to your own target hardware.

  • Found it in ioCC2430.h, which is in the compiler's Program Files directory, and doesn't even show up in the project, and seemingly when you click on "Go to definition of " for something like P1_0, it can't find it.  Anyway, I think we now have a start!  Thanks!