12F1840 config issues


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: 12F1840 config issues

    It looks like 9600 baud by my calculations w/ open wire mode enabled. As far as the config's go everything looks good. Here is my config's for a Waterstick I designed and works great.
    Code:
    DEFINE OSC 32
    
    #CONFIG
    ;----- CONFIG1 Options --------------------------------------------------
      __config _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_ON & _FCMEN_ON
    
    ;----- CONFIG2 Options --------------------------------------------------
      __config _CONFIG2, _WRT_OFF & _PLLEN_ON & _STVREN_ON & _BORV_19 & _LVP_OFF
    #ENDCONFIG
    
    ' ********************************************************************
    '				SYSTEM INITIALIZATION
    ' ********************************************************************
    	clear
    	PORTA = %00000000
    	TRISA = %00001111	'INITIALIZE PORT DIRECTIONS
    	OSCCON = %11110000	'PLL ENABLED,8Mhz,FSOSC<2:0>
       	INTCON = %00000000 'CLEAR GIE,PEIE,TMR0IE,INTE,RBIE,TMR0IF,INTF,RBIF
       	PIE1 = %00000000    'CLEAR ALL INTERRUPT ENABLE BITS
       	PIR1 = %00000000    'CLEAR ALL INTERRUPT FLAGS
      	PIE2 = %00000000    'CLEAR ALL INTERRUPT ENABLE BITS
      	PIR2 = %00000000    'CLEAR ALL INTERRUPT FLAGS
    	APFCON = %00000000	'ALL DEFAULTS
    	ANSELA = %00000011	'AN0:AN1 ANALOG,AN2:AN4 DIGITAL I/O
    	CPSCON0 = %11001100	'ENABLE CAP SENSE,DAC/FVR,HIGH RANGE
    	WPUA = %00001100	'WEAK PULLUP'S OFF, EXCEPT A.2,A.3
      	ADCON0 = %00000000  'CHS2:0,GO/DONE,ADOFF
      	ADCON1 = %11100000  'RIGHT JUSTIFIED,FOSC/64,VSS,VDD
    	SRCON0 = %00000000
    	SRCON1 = %00000000
       	CM1CON0 = %00000000	'CLEAR/DISABLE COMPARATOR
       	CM1CON1 = %00000000	'CLEAR/DISABLE COMPARATOR
      	CMOUT = %00000000	'DISABLE OUTPUT REGISTER
       	DACCON0 = %11001000	'ENABLE DAC,ENABLE POS REFERENCE,SOURCE IS FVR
       	DACCON1 = %00001000	'SET FOR 1/4 SCALE (8) ~ 1.024
      	FVRCON = %10001100	'ENABLE VOLTAGE REFERENCE,4,096
       	OPTION_REG = %00000000 'INTEDG,T0CS,T0SE,PSA,PS
       	T1CON = %11000001	'CAPOSC INPUT,PRESCALER 1/1,START TIMER 1
       	T1GCON = %00000000	'NO GATE CONTROL
       	T2CON = %00000000	'POSTSCALER 1/1,STOP,PRESCALER 1
       	TMR2 = 0			'CLEAR TMR2 MODULE REGISTER
       	PR2 = 255			'SET PERIOD ((((1 / 32,000,000)*4) * 1 PRESCALE) * (1+255 PR2)) = 31.25 KHZ.
       	CCP1CON = %00000000	'PLACE CCP1 INTO DISABLE MODE
       	CCPR1L = $00		'CLEAR CCP1 LOWER 8 BITS
       	CCPR1H = $00		'CLEAR CCP1 UPPER 2 BITS
    	PSTR1CON = %00000001'DEFAULT
    Last edited by Archangel; - 14th February 2015 at 11:21. Reason: code tags
    Dave Purola,
    N8NTA
    EN82fn

  2. #2
    Join Date
    Jul 2003
    Location
    Lancashire
    Posts
    50


    Did you find this post helpful? Yes | No

    Default Re: 12F1840 config issues

    Many thanks, I will run through these and see. These seem tricky beasts to set up and I am sure I have probably not set something I need to. Will report back! Cheers Pete

  3. #3
    Join Date
    Jul 2003
    Location
    Lancashire
    Posts
    50


    Did you find this post helpful? Yes | No

    Default Re: 12F1840 config issues

    I now have the code below. The serial data appears to come out at intervals of one second but is complete garbage still. Replacing the PIC with an appropriately configured 12F683 all functions fine. I am wondering if anyone else can replicate a serout2 on the 12F1840 and see if its the same. If the code looks good I am wondering if its a problem with PBP?. Cheers Pete

    Code:
    :
    #CONFIG
     ;----- CONFIG1 Options --------------------------------------------------
     __config _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_ON & _FCMEN_ON
    
     ;----- CONFIG2 Options --------------------------------------------------
     __config _CONFIG2, _WRT_OFF & _PLLEN_ON & _STVREN_ON & _BORV_19 & _LVP_OFF
     #ENDCONFIG
    
     ' ************************************************** ******************
     ' SYSTEM INITIALIZATION
     ' ************************************************** ******************
     clear
     'PORTA = %00000000
     TRISA  = %00001101	   ' Make A0,A2,A3 inputs,A1,A4,A5 outputs
     OSCCON = %11110000 'PLL ENABLED,8Mhz,FSOSC<2:0>
     OSCTUNE	= %00000000	' Internal osc Adjustment
    WHILE !OSCSTAT.3	' Wait for stable OSC ...
    WEND
     INTCON = %00000000 'CLEAR GIE,PEIE,TMR0IE,INTE,RBIE,TMR0IF,INTF,RBIF
     PIE1 = %00000000 'CLEAR ALL INTERRUPT ENABLE BITS
     PIR1 = %00000000 'CLEAR ALL INTERRUPT FLAGS
     PIE2 = %00000000 'CLEAR ALL INTERRUPT ENABLE BITS
     PIR2 = %00000000 'CLEAR ALL INTERRUPT FLAGS
     APFCON = %00000000 'ALL DEFAULTS
     ANSELA      = %00000000    'Select all digital
     CPSCON0 = %11001100 'ENABLE CAP SENSE,DAC/FVR,HIGH RANGE
     WPUA		= %00000000    'weak pull ups disabled
     ADCON0 = %00000000 'CHS2:0,GO/DONE,ADOFF
     ADCON1 = %11100000 'RIGHT JUSTIFIED,FOSC/64,VSS,VDD
     SRCON0 = %00000000
     SRCON1 = %00000000
     CM1CON0 = %00000000 'CLEAR/DISABLE COMPARATOR
     CM1CON1 = %00000000 'CLEAR/DISABLE COMPARATOR
     CMOUT = %00000000 'DISABLE OUTPUT REGISTER
     DACCON0 = %11001000 'ENABLE DAC,ENABLE POS REFERENCE,SOURCE IS FVR
     DACCON1 = %00001000 'SET FOR 1/4 SCALE (8) ~ 1.024
     FVRCON = %10001100 'ENABLE VOLTAGE REFERENCE,4,096
     OPTION_REG = %00000000 'INTEDG,T0CS,T0SE,PSA,PS
     T1CON = %11000001 'CAPOSC INPUT,PRESCALER 1/1,START TIMER 1
     T1GCON = %00000000 'NO GATE CONTROL
     T2CON = %00000000 'POSTSCALER 1/1,STOP,PRESCALER 1
     TMR2 = 0 'CLEAR TMR2 MODULE REGISTER
     PR2 = 255 'SET PERIOD ((((1 / 32,000,000)*4) * 1 PRESCALE) * (1+255 PR2)) = 31.25 KHZ.
     CCP1CON = %00000000 'PLACE CCP1 INTO DISABLE MODE
     CCPR1L = $00 'CLEAR CCP1 LOWER 8 BITS
     CCPR1H = $00 'CLEAR CCP1 UPPER 2 BITS
     PSTR1CON = %00000001'DEFAULT 
     FVRCON		= 0            'Fixed voltage reference disabled
    
    DEFINE OSC 32
    
    initialise:
    serout2 PORTA.5,16468,["Waiting for X200",13,10]
    pause 1000
    goto initialise
    Last edited by Archangel; - 14th February 2015 at 11:13.

  4. #4
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: 12F1840 config issues

    I guess SEROUT2 has changed for PBP3, because in PBP 2.6, the number 16468 is definitely wrong.
    Anyway, are you seeing any characters correctly? If so, you may need to put a pause between characters. I needed to do this with the 1840 talking to some devices.
    The clock may also be slightly off, causing some characters to get messed up.

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,626


    Did you find this post helpful? Yes | No

    Default Re: 12F1840 config issues

    According to the manual 16468 would be 9600, driven, inverted, no parity. Bit 15 is set which means driven, bit 14 says inverted, bit 13 says no parity. The rest of the bits says 84 which according to the formuala (1000000 / baud - 20) should result in 9600 baud.

    /Henrik.

  6. #6
    Join Date
    Jul 2003
    Location
    Lancashire
    Posts
    50


    Did you find this post helpful? Yes | No

    Default Re: 12F1840 config issues

    Yes 9600 inverted and the same line works correctly on other PIC types I have tried, its only with the 12F1840 it doesnt

  7. #7


    Did you find this post helpful? Yes | No

    Default Re: 12F1840 config issues

    if you cant check clock with frequency meter.......... add in loop once per second (on serout) increment or decrement osctune to see if characters come in view then try to figure about how far off and in what direction (raise/lower freq)
    amgen

Similar Threads

  1. Problem converting 12F683 code to 12F1840
    By RossWaddell in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 14th March 2013, 02:55
  2. PBP Support for 12F1840 8-Pin Device?
    By springtank in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 10th November 2012, 09:32
  3. Timer1 issues
    By mitchf14 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 9th January 2009, 17:21
  4. 12c508a Device Config. And Burning Issues
    By sayzer in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th March 2006, 17:50

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