Intrc Pic16f88


Closed Thread
Results 1 to 6 of 6

Thread: Intrc Pic16f88

  1. #1
    Join Date
    Jun 2005
    Posts
    29

    Default Intrc Pic16f88

    I have a program with a 16F88 at 4MHz internal osc that work but have some little bugs with the serial communication (I have try almost all serial speed). I suspect the internal clock is not accurate so I have build a simple prog to test the INTRC_CLKOUT and adjust it via the OSCTUNE register, but I can't see any clock output at RA6 with an oscilloscope. Here's my test program :

    DEFINE OSC 4
    @ __CONFIG _CONFIG1,_INTRC_CLKOUT&_PWRTE_ON&_MCLR_OFF&_ etc....
    OSCCON = $6E
    ANSEL = $00
    CMCON = $07
    OPTION_REG = %10000000

    LED VAR PORTB.4
    TEMP1 VAR BYTE

    TRISA = %10111111
    TRISB = %11101111
    LED = 0

    START :
    LED = ~LED
    PAUSE 500
    GOTO START


    Thank you if you have any idea

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


    Did you find this post helpful? Yes | No

    Default

    How about
    Code:
    @ __CONFIG _CONFIG1, _INTRC_IO & _DEBUG_OFF & _LVP_OFF & _BODEN_ON & _MCLR_OFF & _PWRTE_ON & _WDT_OFF
    OSCCON=$60
    TRISB=0
    
    Start:
        Toggle PORTB.4
        pause 500
        goto start
    Steve

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

  3. #3
    Join Date
    Jun 2005
    Posts
    29


    Did you find this post helpful? Yes | No

    Default

    Thank you mister_e.

    I think I didn't understood well the last bits of the OSCCON register but now it's ok. Sometimes it's too simple to understand the first time lolll. Now I've tune my internal oscillator to exactly 1.000 MHz (1/4 fosc) but my communication problem is still there (problably another thing I didn't understood). I seems to be a newbie but I do PicBasic Pro and assembly programming since some years but as a hobbyist.

    OK here's my problem with some code exemple. I have 2 PIC, a 16F88 act as the master 4MHz INTRC and a 16F877A as a slave 4MHz XT, they communicate in serial at 2400 Baud. First the master send a 2 byte command to the slave who answer with a 2 string of 16 bytes to be print on a LCD.

    The problem is that it never work the first time! Usually when the command is send, it return only strings of 0. After 2, 3 or more times the command is send, the slave return the correct strings of data. That's why I first think it's a speed problem but it's not.

    Here's some piece of code :
    After the push of a button the master do this

    IDENT :
    SEROUT2 PINOUT,396,["II"] 'Envois le code ASCII "II"
    SERIN2 PININ,396,100,ABSENT,[STR VAL01\16] 'Si pas reponse en 100ms
    SERIN2 PININ,396,[STR VAL02\16] 'va a absent
    LCDOUT $FE,1,STR VAL01\16 'affiche la reponse du module
    LCDOUT $FE,$C0,STR VAL02\15,"." 'ID caché remplacé par un.
    SELECT CASE VAL02[15]
    CASE $00,$01,$10,$11
    PINMAX = 24
    CASE ELSE
    GOTO ABSENT
    END SELECT
    GOSUB PAU2S
    RETURN
    ABSENT :
    LCDOUT $FE,1,"Veillez ins",$00,"rer" 'message si module absent
    LCDOUT $FE,$C0,"un module SVP"
    GOSUB PAU2S
    RETURN


    The code for the slave is :

    START :
    SERIN2 PININ,396,[VAL1,VAL2]
    IF VAL1 = "I" THEN GOTO IDENT
    IF VAL1 = "X" THEN GOTO MESURE
    GOTO START

    IDENT :
    PAUSE 100
    SEROUT2 PINOUT,396,["DIP 40 broches "]
    PAUSE 100
    SEROUT2 PINOUT,396,["Dessus v.1 S.T",$00]
    GOTO START


    Do I have to put pullup or pulldown resistor for serial communication between 2 Pic ?
    If you see anything wrong in my code please let me know. Thank you

    Sorry comments are in french but I think mister_e can read them.

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


    Did you find this post helpful? Yes | No

    Default

    Bien sur que je peut lire et comprendre le tout mon ami

    I'm not going to tell you the answer... but you'll discover it by yourself. Before sending the First set of Byte, use your voltmeter and measure the voltage on your PINOUT pin.

    Now measure it again when a few byte are sent and your PIC is waiting to send other byte.

    Where's the difference? Now place a HIGH or LOW PINOUT at the top of your code, then a PAUSE 50 ( or something like that)

    What's happening now?

    Also be carefull about the Idle state of you PININ. It must met the according level in case no module are insert in the Dip socket. Use pull-up or pull-down to solve it.

    Bonne chance!

    Code:
    LCDOUT $FE,1,"Veillez ins",$00,"rer" 'message si module absent
    Veillez ou Veuillez ?
    Last edited by mister_e; - 2nd June 2006 at 03:19.
    Steve

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

  5. #5
    Join Date
    Jun 2005
    Posts
    29


    Did you find this post helpful? Yes | No

    Default

    Thank you very much mister_e. Now it works as I want.

    Thank you also for the french spelling... But you also have a spelling mistake, You should be called master_e.

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


    Did you find this post helpful? Yes | No

    Default

    The initial idea of Mister E (wich is also the name of my company) was mostely a kind of game with words to have many different meaning.

    Mister E
    Mistery

    Funny that many of my french customer read the Invoice or Business card as mistere and still call me like that (mistere in french = Mistery for those who don't know french)

    On the phone it's not even better... Mister E... no... not Mistery ... Mister E... M-I-S-T-E-R space E

    anyways.. Off topic

    Great to know it's working now!
    Steve

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

Similar Threads

  1. RX TX modules - intermitent communication
    By ruijc in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 11th June 2009, 00:13
  2. pic16f88 & voltage
    By rdxbam in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 17th February 2009, 09:14
  3. intrc question
    By garryp4 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 9th February 2007, 08:17
  4. Replies: 8
    Last Post: - 7th December 2006, 15:42
  5. PIC16F88 problem with TOGGLE command?
    By russman613 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 17th September 2006, 23:31

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