vince

Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • in reply to: timer issue #934
    vince
    Member

    Hi Michael,

    thanks again for your help.

    Here is the Timer part of the VirtualWire.h library. I’m not very comfortable with this part of the code but I guess that it uses Timer1.

    I’ve download the VirtualWire Library v1.9 just here http://www.open.com.au/mikem/arduino/


    // Speed is in bits per sec RF rate
    void vw_setup(uint16_t speed)
    {
    // Calculate the OCR1A overflow count based on the required bit speed
    // and CPU clock rate
    uint16_t ocr1a = (F_CPU / 8UL) / speed;

    #ifndef TEST
    // Set up timer1 for a tick every 62.50 microseconds
    // for 2000 bits per sec
    TCCR1A = 0;
    TCCR1B = _BV(WGM12) | _BV(CS10);
    // Caution: special procedures for setting 16 bit regs
    OCR1A = ocr1a;
    // Enable interrupt
    #ifdef TIMSK1
    // atmega168
    TIMSK1 |= _BV(OCIE1A);
    #else
    // others
    TIMSK |= _BV(OCIE1A);
    #endif

    #endif

    // Set up digital IO pins
    pinMode(vw_tx_pin, OUTPUT); // currently configured to IO pin 12
    pinMode(vw_rx_pin, INPUT);// currently configured to IO 11
    pinMode(vw_ptt_pin, OUTPUT);// currently configured to IO 10
    digitalWrite(vw_ptt_pin, vw_ptt_inverted);// currently configured to IO 0
    }

    Sure you will understand this better than me ::)

    in reply to: timer issue #931
    vince
    Member

    Hi Michael,

    I’ve troubles with the use of and simultaneously and I think it’s due to the Timer part but I don’t know how I can fix this.

    the receiver is not receiving data if I setup “DigitShield.begin();” which is needed to drive the led segments.
    The receiver works and I can watch my data on the Serial if I bypass it “//DigitShield.begin();”
    Of course, the DigitShield library works great if I use it without VirtualWire.


    #include
    #include

    int i;
    int val;

    void setup(){
    Serial.begin(9600);
    vw_setup(9600);
    vw_rx_start();
    DigitShield.begin();
    Serial.println("Ready");
    }

    void loop(){
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;
    if (vw_get_message(buf, &buflen)) { // check to see if anything has been received
    for (i = 0; i < buflen; i++) {
    val = buf;
    Serial.print("temp :");
    Serial.println(val);
    DigitShield.setValue(val);
    }
    }
    }

    Hope you will have suggestions.
    Regards
    Vince

Viewing 2 posts - 1 through 2 (of 2 total)