+ Reply to Thread
Results 1 to 20 of 24

Thread: CLKFREQ mysteriously jumps from 80mhz to 824,195,128

Hybrid View

  1. #1

    Default CLKFREQ mysteriously jumps from 80mhz to 824,195,128

    I could not figure out what was going on with my interrupts, all of a sudden the interrupts were taking roughly 10x longer between executions.
    this is my clock setup
    _clkmode = XTAL1 + PLL16x
    _xinfreq = 5_000_000

    at boot up CLKFREQ returns 80,000,000 as expected, then after writing to the SD card once it returns 824,195,128 instead. (using fsrw.spin) then it appears to stay put. essentially making all of the waitcnt instructions take a little over 10 times longer.

    I've had other strange things with this board as well, for instance if I use SD-MMC_FATEngine instead, then the SD driver will not operate if GPS_IO_mini.spin is used in the same project. I suspect that some resource is being shared not so well but I cannot figure out which one.
    Last edited by R Pankau; 03-23-2012 at 04:41 PM.

  2. #2

    Default Re: CLKFREQ mysteriously jumps from 80mhz to 824,195,128

    I bet there is a bug in your code. FSRW is very well testes like all objects in the object exchange.

    By the way ... what do you mean with interrupts? There is no such concept for propellers.

    Waitcnt needing longer than expected you have when you just missed the cnt!

    You should post your code!

  3. #3

    Default Re: CLKFREQ mysteriously jumps from 80mhz to 824,195,128

    Suspiciously 824195128 is $31203838, valid ASCII, which is the string fragment "88 1" - so a memory overwrite is most likely.

  4. #4

    Default Re: CLKFREQ mysteriously jumps from 80mhz to 824,195,128

    The CLKFREQ value is located at location 0. It appears that you are writing to location 0. You may be using a NULL pointer somewhere. This kind of error could happen if you did something like BYTEMOVE(buffer, string("88 1"), 4) instead of BYTEMOVE(@buffer, string("88 1"), 4), and buffer is an uninitialized VAR variable that would contain a zero.

  5. #5

    Default Re: CLKFREQ mysteriously jumps from 80mhz to 824,195,128

    Very insightful, I think the offending piece of code lies in this that I used from OBEX
    Code:
    PUB readNEMA
      Null[0] := 0
      repeat
       longfill(gps_buff,20,0)
       repeat while Rx <>= "$"      ' wait for the $ to insure we are starting with
         Rx := uart.rx              '   a complete NMEA sentence 
       cptr := 0
    
       repeat while Rx <>= CR       '  continue to collect data until the end of the NMEA sentence 
         Rx := uart.rx              '  get character from Rx Buffer
         if Rx == ","
           gps_buff[cptr++] := 0    '  If "," replace the character with 0
         else
           gps_buff[cptr++] := Rx   '  else save the character   
       
       if gps_buff[2] == "G"             
         if gps_buff[3] == "G"            
           if gps_buff[4] == "A"            
               copy_buffer(@GPGGAb, @GPGGAa)
    
       if gps_buff[2] == "R"             
         if gps_buff[3] == "M"            
           if gps_buff[4] == "C"           
               copy_buffer(@GPRMCb, @GPRMCa)
                       
       if gps_buff[0] == "P"
        if gps_buff[1] == "G"  
         if gps_buff[2] == "R"
          if gps_buff[3] == "M"  
           if gps_buff[4] == "Z"
               copy_buffer(@PGRMZb, @PGRMZa)
    
    
       if gps_buff[0] == "G"
        if gps_buff[1] == "P"
         if gps_buff[2] == "G"
          if gps_buff[3] == "S"
           if gps_buff[4] == "A"
               copy_buffer(@GPGSAb, @GPGSAa)
    The ascii 88 1 is the first four chars of Longitude.
    the "Null[0] right off the bat has me thinking that it's writing to location zero.

    the "interrupt" I refer to is just this, running it a separate cog.
    Code:
    PUB interrupt
    repeat
      waitcnt(80_000_000 + cnt)
      cntr++
    and I use cntr a global var to trigger subs then clear cntr,then wait again. I had CLKFREQ in the waitcnt instruction at first then switched it to 80Mhz and noticed that things began working better.

    I also use byte addressing in this, which is where all the writing to the sd card happens. but I believe it should never affect location zero....requires a closer look though.


    Code:
    pub write_sd(landmark)  |address, i
    
      ret_val := \sd.popen(string("Log01.txt"),"a")
          if landmark == 2
              \sd.SDstr(gps.GPSaltitude)
              \sd.SDstr(string(", "))
    
              'bytefill(@lat_and_long,0,15)  'Clear Buffer
              address := gps.latitude   'Get address of latitude
              byte[lat_and_long][0] := byte[address][0]
              byte[lat_and_long][1] := byte[address][1]
              byte[lat_and_long][2] := " "
              i := 3
              repeat 7
                byte[lat_and_long][i] := byte[address][i-1]
                i++
              byte[lat_and_long][i] := 0  
              \sd.SDstr(lat_and_long)
              \sd.SDstr(string("N, "))
              
              'bytefill(@lat_and_long,0,15)  'Clear Buffer
              address := gps.longitude   'Get address of longitude
              byte[lat_and_long][0] := byte[address][1]
              byte[lat_and_long][1] := byte[address][2]
              byte[lat_and_long][2] := " "
              i := 3
              repeat 7
                byte[lat_and_long][i] := byte[address][i]
                i++
              byte[lat_and_long][i] := 0   
              \sd.SDstr(lat_and_long)
    
              \sd.SDstr(string("W, ")) 
              \sd.SDstr(gps.satellites)
              \sd.SDstr(string(", "))
              \sd.SDstr(gps.valid)
              \sd.SDstr(string(", "))
              \sd.SDstr(gps.time)
              \sd.SDstr(string(", "))
              \sd.SDstr(gps.heading)
              \sd.SDstr(string(", "))
              \sd.SDstr(gps.speed)
              \sd.SDstr(string(", "))
              \sd.SDstr(gps.date)
              \sd.SDstr(string(" ",13,10))
              'debug.str(string("test"))
              'debug.dec(ret_val)
              'debug.tx(13) 
              \sd.pflush
              \sd.pclose
              'debug.str(string("after file close",13,10))
             
    
          if landmark == 1
              \sd.SDstr(gps.GPSaltitude)
              \sd.SDstr(string(", "))
              \sd.SDstr(gps.latitude)
              \sd.SDstr(string(", -"))
              \sd.SDstr(gps.longitude)
    
              
              \sd.SDstr(string(", "))
              \sd.SDstr(gps.satellites)
              \sd.SDstr(string(", "))
              \sd.SDstr(gps.valid)
              \sd.SDstr(string(", "))
              \sd.SDstr(gps.time)
              \sd.SDstr(string(", "))
              \sd.SDstr(gps.heading)
              \sd.SDstr(string(", "))
              \sd.SDstr(gps.speed)
              \sd.SDstr(string(", "))
              \sd.SDstr(gps.date)
              \sd.SDstr(string(", Landmark"))
              \sd.SDstr(string(" ",13,10))
              'debug.str(string("test"))
              'debug.dec(ret_val)
              'debug.tx(13) 
              \sd.pflush
              \sd.pclose
    
          if ret_val == 0
            outa[Green_LED] := 1              'Blink LED for success.  
            waitcnt(clkfreq/100 + cnt)
            outa[Green_LED] := 0
    
          if ret_val <> 0  
            outa[Blue_LED] := 1              'Blink LED for NOT success.  
            waitcnt(clkfreq/2 + cnt)
            outa[Blue_LED] := 0
    maybe I should have used byte[@lat_and_long][0], I assumed that referencing a var array would return the address of the first byte, but.... now I see that by clearing the array to zero, or if it starts out that way, the byte[effectively zero][0] then writes to location zero.
    Last edited by R Pankau; 03-23-2012 at 01:56 PM. Reason: ahah

  6. #6

    Default Re: CLKFREQ mysteriously jumps from 80mhz to 824,195,128

    This should work a little better
    Now if I could find the switch to turn off "unsolved" on the forum heading.

    Code:
    pub write_sd(landmark)  |address, i
    
      ret_val := \sd.popen(string("Log01.txt"),"a")
          if landmark == 2
              \sd.SDstr(gps.GPSaltitude)
              \sd.SDstr(string(", "))
    
              'bytefill(@lat_and_long,0,15)  'Clear Buffer
              address := gps.latitude   'Get address of latitude
              byte[@lat_and_long][0] := byte[address][0]
              byte[@lat_and_long][1] := byte[address][1]
              byte[@lat_and_long][2] := " "
              i := 3
              repeat 7
                byte[@lat_and_long][i] := byte[address][i-1]
                i++
              byte[@lat_and_long][i] := 0  
              \sd.SDstr(lat_and_long)
              \sd.SDstr(string("N, "))
              
              'bytefill(@lat_and_long,0,15)  'Clear Buffer
              address := gps.longitude   'Get address of longitude
              byte[@lat_and_long][0] := byte[address][1]
              byte[@lat_and_long][1] := byte[address][2]
              byte[@lat_and_long][2] := " "
              i := 3
              repeat 7
                byte[@lat_and_long][i] := byte[address][i]
                i++
              byte[@lat_and_long][i] := 0   
              \sd.SDstr(lat_and_long)
    
              \sd.SDstr(string("W, ")) 
              \sd.SDstr(gps.satellites)
              \sd.SDstr(string(", "))
              \sd.SDstr(gps.valid)
              \sd.SDstr(string(", "))
              \sd.SDstr(gps.time)
              \sd.SDstr(string(", "))
              \sd.SDstr(gps.heading)
              \sd.SDstr(string(", "))
              \sd.SDstr(gps.speed)
              \sd.SDstr(string(", "))
              \sd.SDstr(gps.date)
              \sd.SDstr(string(" ",13,10))
              'debug.str(string("test"))
              'debug.dec(ret_val)
              'debug.tx(13) 
              \sd.pflush
              \sd.pclose
              'debug.str(string("after file close",13,10))
             
    
          if landmark == 1
              \sd.SDstr(gps.GPSaltitude)
              \sd.SDstr(string(", "))
              \sd.SDstr(gps.latitude)
              \sd.SDstr(string(", -"))
              \sd.SDstr(gps.longitude)
    
              
              \sd.SDstr(string(", "))
              \sd.SDstr(gps.satellites)
              \sd.SDstr(string(", "))
              \sd.SDstr(gps.valid)
              \sd.SDstr(string(", "))
              \sd.SDstr(gps.time)
              \sd.SDstr(string(", "))
              \sd.SDstr(gps.heading)
              \sd.SDstr(string(", "))
              \sd.SDstr(gps.speed)
              \sd.SDstr(string(", "))
              \sd.SDstr(gps.date)
              \sd.SDstr(string(", Landmark"))
              \sd.SDstr(string(" ",13,10))
              'debug.str(string("test"))
              'debug.dec(ret_val)
              'debug.tx(13) 
              \sd.pflush
              \sd.pclose
    
          if ret_val == 0
            outa[Green_LED] := 1              'Blink LED for success.  
            waitcnt(clkfreq/100 + cnt)
            outa[Green_LED] := 0
    
          if ret_val <> 0  
            outa[Blue_LED] := 1              'Blink LED for NOT success.  
            waitcnt(clkfreq/2 + cnt)
            outa[Blue_LED] := 0

+ Reply to Thread

Similar Threads

  1. PASM, PPDB and Mysteriously lit LED?- solved
    By Tony B. in forum Propeller 1 Multicore Microcontroller
    Replies: 6
    Last Post: 07-19-2011, 12:56 PM
  2. What are the standard clkfreq values above 80MHz?
    By Kye in forum Propeller 1 Multicore Microcontroller
    Replies: 29
    Last Post: 07-09-2010, 06:51 AM
  3. Why is X := clkfreq * 15/10_000 not the same as X := clkfreq *150/100_000 ?
    By SteveWoodrough in forum Propeller 1 Multicore Microcontroller
    Replies: 2
    Last Post: 03-14-2010, 12:12 AM
  4. Robot jumps over walls
    By Fxc2hh in forum General Discussion
    Replies: 2
    Last Post: 09-19-2009, 02:48 AM
  5. PASD jumps here and there...
    By nicolad76 in forum Propeller 1 Multicore Microcontroller
    Replies: 2
    Last Post: 04-18-2008, 04:50 AM

Tags for this Thread

Bookmarks

Posting Permissions

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