A few 12F683 questions


+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2005
    Posts
    1,073

    Default A few 12F683 questions

    I recently lost a HDD and with it my notes on a project. So, I have a few questions for which I hope to find answers, saving a bit of research effort.

    I will be using a 12F683 (8MHz internal oscillator) and an ASK RF receiver module with +/-10kHz bandwidth to capture several RF codes from various sources. The codes vary in frequency (310-320MHz), start sequence (initial pulses vary from ~2mS to 9mS), length (i.e.number of bits), and protocols. Some have constant length pulses with the following spaces varying for 1 vs. 0 (e.g. NEC) while others are just the opposite with constant length spaces preceded by pulses that vary in length (e.g. Sony). In each case, it's the time between rising edges that determine 1 or 0. The long bit-times are 2.0-2.4mS and the short ones half of that. All but one of the codes terminate with a lengthy silence. The longest code has 44 bits. The one code that does not have a terminating silence has a 2mS start pulse while the only code with 44 bits has a 9mS start pulse so I can determine which is which based on their start pulses. I also wish to measure the amplitude of the RF receiver's analog output. I've found that measuring the modulation depth (pulse amplitude - space amplitude) is an excellent proxy for RSSI (Received Signal Strength Indicator). I do not plan to use interrupts.

    My algorithm...

    1. Wait for rising edge
    2. Measure amplitude of start pulse
    3. Wait for falling edge
    4. Calculate duration of pulse - if out of limits reset and wait for next pulse
    5. Measure amplitude of space (pulse-space=RSSI)
    6. Capture up to 44 bits - using CCP1 set for rising edges - reset TMR0 to overflow at ~2.6mS
    7. Output results via RS232 (and store for response to RS485 query).

    The algorithm itself works fine using another processor (ZX-40a from ZBasic) although the timeout function is slightly different. It uses an overall timeout value rather than the 2.6mS value I plan to use on a per bit basis.

    My questions:

    1. How do I set the TMR1 prescale value to 2?
    T1CON=%00010000?
    2. What values (preset, prescale) do I need for TMR0 for a 2.6mS overflow?
    TMR0=93?, OPTION_REG=%10000011?
    3. With interrupts disabled, can I monitor the IOC flag (INTCON.0) to detect when there's an input on one of the two serial inputs (RS232 & RS485)? They will send $FF one or more times to get the receiver's attention.

  2. #2
    skimask's Avatar
    skimask Guest

    Default

    1. Yes...
    2. Sounds about right to me...
    3. Datasheet says you've gotta have INTs enabled...but the way it reads, it almost sounds like you don't NEED to have them enabled, in which case, you'd have to read the individual bits themselves.

  3. #3
    Join Date
    Dec 2005
    Posts
    1,073

    Default

    Thanks for confirming my timer configurations.

    On #3, I think we read the datasheet the same way. I believe most, if not all, interrupt flag bits get set whether or not interrupts are enabled. For example, the CCP1 Capture flag (PIR1.2) gets set even though interrupts are disabled. For most, this is usually stated explicitly in the datasheet but, in this case, the datasheet is a bit murky. Since I'll be using While !Capture:Wend loops to wait for rising/falling edges, I'll also monitor the IOC flag (INTCON.0) within the loops and then check the individual pins to determine whether it was set by an RS232 input or RS485 input. Otherwise, I'll just monitor both input pins within the loops.

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405

    Default

    #2. With a Timer0 reload value of 93, OPTION_REG = %10000100 would give you ~2.6mS
    overflow rate @8MHz.

    Note there's a 2-cycle inhibit period when writing to Timer0.

    #3. Yes. I do this all the time. You can enable individual interrupts and just monitor/reset
    each flag bit without global interrupts enabled.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  5. #5
    Join Date
    Dec 2005
    Posts
    1,073

    Default

    Thanks, Bruce.

    #2 That's what I get for doing the math in my head.

    #3 Actually, I'm adapting (i.e. stealing) one of your examples for the capture module.

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    No need for math... PICMultiCalc is all you need

    http://www.mister-e.org/pages/utilitiespag.html
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Dec 2005
    Posts
    1,073

    Default

    Quote Originally Posted by mister_e View Post
    No need for math... PICMultiCalc is all you need
    My copy was on the dead HDD and I couldn't recall the name.

Similar Threads

  1. 12F683 - Pin1 not working
    By ruijc in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th February 2014, 17:38
  2. New project help rapidfire on 12f683
    By thm ov3rkill in forum mel PIC BASIC Pro
    Replies: 27
    Last Post: - 27th December 2008, 19:59
  3. 12F683 Programmer
    By Red_Stafford in forum Schematics
    Replies: 9
    Last Post: - 2nd October 2008, 21:44
  4. 16f677a to 12f683
    By ChrisHelvey in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 25th July 2007, 06:16
  5. 12f683 comparator and pwm
    By Automan in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 23rd May 2007, 18:05

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts