Problem with 16F648A


Closed Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120

    Smile Problem with 16F648A

    Hello to everybody,

    I use the 16F648A with internal OSC 4Mhz and I power it with 3VDC.The microcontroller does not work well.
    I do not manage to find the fault of my code!!!!!
    Have a look to the BEGIN MAIN LOOP (of my code).THE IF condition never get TRUE!!!!(That is the reason I add the blink led)
    Please have a look and advice
    ----------------------------------------------------------------------
    include "modedefs.bas"
    @ DEVICE pic16F648A, INTRC_OSC_NOCLKOUT ' system clock options
    @ DEVICE pic16F648A, WDT_ON ' watchdog timer
    @ DEVICE pic16F648A, PWRT_ON ' power-on timer
    @ DEVICE pic16F648A, MCLR_OFF ' master clear options (internal)
    @ DEVICE pic16F648A, BOD_OFF ' brown-out detect
    @ DEVICE pic16F648A, LVP_OFF ' low-voltage programming
    @ DEVICE pic16F648A, CPD_OFF ' data memory code Protect
    @ DEVICE pic16F648A, PROTECT_OFF ' program code protection


    PAUSE 500
    DEFINE OSC 4 'OSC MUST BE SET TO HS

    'general purpose variables
    i VAR BYTE
    counter var byte

    'pin definitions for comm w/ Laipec TRW-24G
    RF_CE var PORTB.7
    RF_CS var PORTB.6
    RF_DR var PORTB.5
    'channel 1
    RF_CLK1 var PORTB.4
    RF_DATA_Out var PORTB.3

    ' THIS IS THE ADDRESS FOR THE w/ Laipec TRW-24G
    WhichAddress1 var byte 'Channel 1
    WhichAddress2 var byte 'Channel 2

    'constants for RF configuration modes
    CONRFRX var byte
    CONRFTX var byte

    'indicates state of current RF configuration - TX is 0, RX is 1
    RFCurrentState var bit

    'hold data for RF message
    RFDataArrayIN var byte[4]
    RFDataArrayOUT var BYTE[4]

    'hold data for RF configuration
    RFConfigArray var Byte[16]

    'variables for each received or sent message
    msgFromID var word
    msgToID var word
    msgData1 var word
    msgData2 var word
    SerialData VAR BYTE
    sendLED var PORTA.0
    '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''

    bootup:
    WhichAddress1 =$BA
    WhichAddress2 =$BA
    PORTA = %00000000;
    TRISA = %00011110; ' 0 = Output, 1 = Input (A.1 is RxPC)

    PORTB = %00000000;
    ;TRISB = %01101010; ' 0 = Output, 1 = Input (C.1 is RF_DATA_In, C.3 is RF_DR)


    'intialize RF module configuration
    'constants to define receive/transmit modes at 2402 Mhz frequency
    CONRFTX = $04
    RFCurrentState = CONRFTX

    GOSUB initRFConfig

    '************************BEGIN MAIN LOOP***********************'

    start:

    IF PORTA.1 = 1 THEN A
    goto start

    A: low RF_CS ' bring CS low before turning CE high - only one high at a time!
    HIGH RF_CE ' bring CE high to bring RF into active mode
    high sendLED
    pause 1000
    low sendLED
    msgToID = 000 ' CHANGE THIS TP WHO SHOULD RECIEVE MESSAGE
    msgFromID = 001
    msgData1 = 001 ' DATA SENT
    msgData2 = 000
    gosub sendData ' goto the sendData function
    pause 200
    goto start


    sendData : mpla
    mpla
    mpla

    RETURN
    END

  2. #2
    Join Date
    Oct 2004
    Location
    North Norfolk UK
    Posts
    146


    Did you find this post helpful? Yes | No

    Default

    Hi

    I cannot see that you have set the PORTA register to digital, have a look at the sheet for the device you are using, there is also a paragrapgh in the manual that discusses this specific issue, worth taking a look for the future.



    HtH

    Duncan

  3. #3
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120


    Did you find this post helpful? Yes | No

    Thumbs down

    My friend duncan303,

    Last I looked the 16F628 didn't have A/D Converters and as such doesn't have ADCON Registers - but you might want to correct me on that...


    Nikos

  4. #4
    Join Date
    Oct 2004
    Location
    North Norfolk UK
    Posts
    146


    Did you find this post helpful? Yes | No

    Default

    hi Nikos,

    Are you on 16F628 or on the 16F648A, they are not identical the datasheets are similar but differrent, one is the A series.

    No matter, I have got the 16F62X sheet open at the moment, the register associated with the PortA is listed on page 34 table 5.2, therefore you will be looking at the CMCON register, if you look in the PBP manual on page 10 it will help explain better than I can right now, just off for my Sunday roast


    Mmm hungry

    Duncan

  5. #5
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hi ngeronikolos,
    Please read this thread:
    http://www.picbasic.co.uk/forum/showthread.php?t=543
    You will see to use internal Osc does not require you to set osc to HS, are you doing that manualy in the programmers fuse?, I ask because of your comment in define statement?
    Early in your code put CMCON = 7 to disable comparators.
    your statement:
    Code:
    'constants for RF configuration modes
    CONRFRX var byte
    CONRFTX var byte
    these are set as variables not constants.
    Call to nonexistant sub directory: GOSUB initRFConfig
    What is " mpla " ?
    your
    Code:
     'constants to define receive/transmit modes at 2402 Mhz frequency
    CONRFTX = $04
    RFCurrentState = CONRFTX
    If you had properly set those as constants, I do not think you could redefine them later in code, since you set them as VAR it works. to make them constants just rewrite as:
    Code:
     CONRFTX CON $04
    'at the beginning, then you give the variable RFCurrentState it's value as above RFCurrentState = CONRFTX .
    This is your statament:
    @ DEVICE pic16F648A, INTRC_OSC_NOCLKOUT ' system clock options
    Change to :
    @ DEVICE pic16F648A, INTOSC_OSC_NOCLKOUT ' use internal OSC instead of R/C osc
    If you installed everything in the default places when you setup PBP then you should find a file called P16F648A in this directory:C:\Program Files\Microchip\MPASM Suite , open it and look at the last several lines to see all available config fuses for this chip.
    Last edited by Archangel; - 2nd March 2008 at 19:57.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  6. #6
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120


    Did you find this post helpful? Yes | No

    Red face

    I do not manage to fix my problem.I add the CMCON = 7 to disable comparators...BUT NOTHING.

    But I found something strange and I would like your advice.
    I use Microcode Studio Plus 3.0.0.5, compiler PBP 2.47, programmer Pickit2.
    I compile my code and I program my pic with the .hex generated file.After that I read the pic and the .hex file is not the same(same changes).

    LOOK the attaches file
    Attached Files Attached Files

  7. #7


    Did you find this post helpful? Yes | No

    Default

    Since you are running at 3V you may have an input level problem. If the IF PORTA.1 = 1 never goes true, the hardware just may not be seeing the proper level. If the input pin is "TTL" level then it needs a voltage level of (.25 VDD + 0.8V) for a '1'. If it is a schmitt trigger then it needs at least 0.8VDD for a '1'. Sometimes it is the simple stuff you need to check.

  8. #8
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120


    Did you find this post helpful? Yes | No

    Cool

    falingtrea,

    The condition IF PORTA.1 = 1 never goes true either using 5vdc.I do not think that is level "1" the problem.

    I will try to de-install the Microcode Studio Plus + pICKIT2 because it seems to me that the problem is from the pc.

    If someboby have any other idea please advice

    Regards
    Nikos

  9. #9


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by ngeronikolos View Post
    I do not manage to fix my problem.I add the CMCON = 7 to disable comparators...BUT NOTHING.

    But I found something strange and I would like your advice.
    I use Microcode Studio Plus 3.0.0.5, compiler PBP 2.47, programmer Pickit2.
    I compile my code and I program my pic with the .hex generated file.After that I read the pic and the .hex file is not the same(same changes).

    LOOK the attaches file
    If you look closely you will see that from address 0 to 2FF the data is the same. After that the difference between the files is that the read is showing all the blank locations of the total memory for the PIC device. This is normal.

  10. #10


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by ngeronikolos View Post
    falingtrea,

    The condition IF PORTA.1 = 1 never goes true either using 5vdc.I do not think that is level "1" the problem.

    I will try to de-install the Microcode Studio Plus + pICKIT2 because it seems to me that the problem is from the pc.

    If someboby have any other idea please advice

    Regards
    Nikos
    This may be a stupid question but have you verified that the signal on PortA.1 is working the way you expect it? What is driving this pin? If it is some kind of open-collector output, for instance, it needs a pullup in order to generate a '1'. I always check the hardware before I assume there is a problem with the software. I can't remember how many times I have put the wrong kind of signal on a pin and wondered why the software did not work.

  11. #11
    Join Date
    Feb 2005
    Location
    GREECE
    Posts
    120


    Did you find this post helpful? Yes | No

    Default

    Finally falingtrea show me the way to solve my <<stupid>> problem.
    I add pull down resistor to PORTA.1...and that's it.ok

    HARDWARE
    Thanks boys
    Nikos

Similar Threads

  1. Code doesn't work on 16F648A
    By Mr_Joe in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 1st September 2018, 22:09
  2. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 08:12
  3. Hardware problem or what ?
    By Steve S. in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 4th March 2007, 21:39
  4. 1 slave 1 master 1 MAX232 1 problem ?
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 31st July 2005, 22:59
  5. weird 12F629/675 problem
    By peterdeco1 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 7th October 2004, 01:08

Members who have read this thread : 1

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