RF12 module need to convert some C to Basic


Closed Thread
Results 1 to 40 of 44

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    Did you find this post helpful? Yes | No

    Default

    Here come the colon again!

    Well, Dave, actually you are running the Oscillator of the PIC at 4MHz, but the core is running at 1MHz (/4).

    If you want the pic running at 10MHz, then you should capitalize the define on top of the program as Skimask stated like this:

    DEFINE OSC 10

    After that, compiler will take care of the rest timing.

    Ioannis

  2. #2
    Join Date
    Dec 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default Osc

    Ioannis...

    I had defined the osc to 10, the problem was that at startup, the RFM12 only puts out a 1Mhz clock signal, and at that speed, it would not initialize the RFM12... Not exactly sure why.. I did some mucking around last night, and have now got it to start on 1Mhz, write to the LCD first, then initialize the RFM12. I'm not sure why but it did not want to do this the other way around.

    I'm glad I am now making progress..

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    Did you find this post helpful? Yes | No

    Default

    Let me understand what you are doing. You are clocking the PIC from a 1MHz RFM12 output?

    Ioannis

  4. #4
    Join Date
    Dec 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default clock

    on first turn-on, the RFM12 outputs a 1Mhz osc for the pic, which I am putting in on OSC1.
    After I write the command ... dout = $C0F7 : gosub Writecmd ... this changes that osc freq from 1MHz to 10MHz... so my pic will run at 10MHz. I have figured out the problem to just be that my crystal setting was on XT, not HS.

    I am onto the next part of converting C to Basic if anyone dare to assist....
    Code:
    void WriteFSKbyte( uchar DATA )
    {
      uchar RGIT=0;
      uint temp=0xB800;
      temp|=DATA;
    Loop: SCK = 0;
      nSEL=0;
      SDI=0;
      SCK=1;
      if(SDO)         //polling SDO
      {
        RGIT=1;
      }
      else
      {
        RGIT=0;
        WriteCMD(temp);
      }
    }
    So far I have...

    Code:
    WriteFSKbyte:
    temp = $B800
    
    Loop:
    SCK = 0
    nSEL = 0
    SDI = 0
    SCk = 1
    if SDO = 1 then
      rgit = 1
    else
      rgit = 0
    endif
    SCK = 0
    SDI = 1
    nSEL = 1
    if rgit = 0 then
      goto loop
    endif
    rgit = 0
    dout = temp
    gosub writecmd
    return
    The part I am struggling with right now is...

    Code:
      uchar RGIT=0;
      uint temp=0xB800;
      temp|=DATA;
    Does this take bit 0 of DATA and stick it to temp somehow??

    Someone with some C knowledge please help me!

    Thanks!

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    Did you find this post helpful? Yes | No

    Default

    Why are you compilcating things?

    Just put a crystal or resonator on the pic and have it working on a precise time base. What you are doing now is screwing the timing of the commands and may be locks the pic at the time the freq. is changing. Also at 4MHz and lower the PIC should use XT settings and above that HS settings.

    I strongly recommend the PIC using its own clock.

    Ioannis

  6. #6
    Join Date
    Dec 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Post Complicating..

    This is mostly just an excercise for a project of mine. The way the module is toted, is that it can output a clock signal for the pic, so only the crystal on the module is needed, and not 2 seperate oscillators. The examples I have seen of this module being used in the real world have had the osc out line connected to the pic. I have now got this part working though, and it is not a problem.

    Cheers

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


    Did you find this post helpful? Yes | No

    Default

    Do you have to reset the registers each time the RF12 starts or are they non-volatile so that the clock frequency will always be 10MHz (or whatever) once set? In my experience, registers like these are usually non-volatile.

Similar Threads

  1. Version Control
    By btaylor in forum mel PIC BASIC Pro
    Replies: 33
    Last Post: - 16th October 2011, 18:12
  2. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 9th December 2008, 00:40
  3. Replies: 1
    Last Post: - 27th July 2008, 07:14
  4. using AND as an IF statement
    By dw_pic in forum mel PIC BASIC
    Replies: 27
    Last Post: - 8th June 2006, 19:05
  5. convert Basic Stamp2 (BS2) => Pic
    By bs2rdu in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 15th September 2005, 20:55

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

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