Menu

New chip new question

Help
2011-04-05
2013-05-30
  • Djbillyd007

    Djbillyd007 - 2011-04-05

    At the moment I am experimenting with a 16f610. I have 10 of them. Every time I use the wait command in gc graphical the chip hangs. Is there somethig that needs to be set to allow the wait command to work. It will work if I keep the time down to 1 micro second. If I put in anything higher it hangs. I have read the data sheet over and over and must be missing something. There are several things I don't yet understand about this chip.

     
  • Djbillyd007

    Djbillyd007 - 2011-04-06

    Here is the code that doesn't seam to work>

    ;Chip Settings
    #chip 16F610,8

    Dir PORTC.3 Out
    Do Forever
    Wait 2 s
    Set PORTC.3 On
    Loop

    Removing the wait allows the code to work.  Putting in a 1microsecond value also works. I put portc.4 in front of the wait and it comes on but nothing I code after the wait works. I played with every configuration bit that I thought might do something. I then played with the ones that didn't make sense. I have read the data sheet over and over but no help. I do have lots and lots of questions about serial programming after I learn a little more about what I am doing. I thought maybe i was somehow making the chip go into program but to my understanding mclr would have to be at a high voltage. Is this correct?

     
  • Djbillyd007

    Djbillyd007 - 2011-04-06

    I am using  a pickit2 to program with if that helps.

     
  • Nobody/Anonymous

    It looks like a compiler problem with the 16f610.  The memory map for variables is supposed to start at 0x40 or dec 64.  GCBasic is trying to stuff them in at 0x20 or dec 32, which would be fine if it was a 16f616.  I don't have the latest download, so can't say if it has been fixed, or needs to be fixed.

    Kent

     
  • Nobody/Anonymous

    You could try editing the 16F610.dat file in the chipdata directory of GCBasic. Edit two sections towards the bottom of the file with the following values -

    [FreeRAM]
    40:6F
    [NoBankRAM]
    70:7F
    

    That should fix the problem.

     
  • Djbillyd007

    Djbillyd007 - 2011-04-07

    That got it. Thank you very much. Honestly I don't know what I did though. Could someone please explain a little more or point me in the right direction to read more about it. Also I have another odd thing happening. If I have portc.3 on and then do anything else to any of the portc pins on then portc.3 goes off. I can work around this but curious as to why.

     
  • Nobody/Anonymous

    The dat file provides GCBasic with information about the chip being used such as how much program memory it has, where and what registers it has and where the general purpose RAM is located but in the 16F610 dat file there was a mistake in the definition of the RAM addresses. This lead GCBasic to store system variables for the wait in memory locations which aren't usable so the program crashed or froze. (For short microsecond waits GCBasic probably doesn't use any variables)

    The FreeRAM section of the dat file lists blocks of RAM that are accessible in one bank of the data memory - the 16F610 only has one block in bank 0 from 40 to 6F in hex.

    The NoBankRAM section lists blocks of RAM that are accessible from any bank and is (nearly?) always from 70 to 7F hex for 12F/16F chips at least.

    Could you post some code for the portc.3 problem?

     
  • Nobody/Anonymous

    Actually the portc.3 problem could be a result of the ANSEL register not being cleared. That would normally be done by gcbasic in the INITSYS subroutine that it generates but as the 16F610 only has analog inputs for the comparator and no ADC ANSEL is not being cleared. Having an output pin also set as an analog input causes odd things to happen when the pin is read - I think it always reads as 0 and since a lot of port operations involve a read-modify-write sequence portc.3 is being cleared when you do something else on the port.

    Add a line to your code to clear ANSEL and see if that fixes it -

    ;Chip Settings
    #chip 16F610,8
    ANSEL = 0
    
     
  • Djbillyd007

    Djbillyd007 - 2011-04-07

    Ansel = 0  got it. Thanks. I should have caught that had a similur problem on another chip. Slow learner I guess :). As far as the memory is concerned, great explaination I think I understand it. I am going to print out the .dat file and compare it to datasheet and see if I can get a better handle on what the rest of it is doing. In the mean time I will start adding some code to this chip and see what I can learn. I have a few project ideas for this on my model railroad.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.