12-bit core issues


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2005
    Posts
    1,073

    Unhappy 12-bit core issues

    I need to replace the 12C508A in a device. I need more memory since PBP isn't as efficient as ASM. The original 12C508A is a wide SOIC-8 and I can only get 12C509A or 12F509 with that footprint.

    My code for the 12F509 doesn't work - there's no output after the copyright message - but the same code works using a 12F629.

    12F629
    Code:
    '=======================| RF RECEIVER |=========================
    'MR26X629.BAS
    'PIC12F629 @ 4MHz          478 words		uses MPASM
    
    'Pin 1 - Vdd
    'Pin 2 - GPIO.5
    'Pin 3 - GPIO.4
    'Pin 4 - GPIO.3
    'Pin 5 - GPIO.2 RS232 output @ 9600bps
    'Pin 6 - GPIO.1 Receives up to 48 bits of PDM/PWM RF with lead-in of 2-9mS
    'Pin 7 - GPIO.0
    'Pin 8 - Vss
    '===============================================================
    
    @ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_OFF 
    
    DEFINE OSCCAL_1K 1 
    DEFINE OSC 4					
    DEFINE DEBUG_REG GPIO
    DEFINE DEBUG_BIT 2 				
    DEFINE DEBUG_MODE 1 				
    DEFINE DEBUG_BAUD 9600
    	
    RF      VAR 	byte[6]
    period	VAR 	word
    i       VAR 	byte   
    bits	VAR	byte
    bytes	VAR	byte           	
    sof  	VAR 	byte
    x       VAR     byte
    	       
            CMCON     	=%00000111      'disable comparators        
            INTCON		=%00000000	'disable interrupts	
            OPTION_REG	=%10000101	'TMR0 1:64 prescaler
                    
            DEBUG "MR26X",13,10
            Debug "Copyright ",169," 2009 dlh",13,10
          
    init:	RF[0]=0:RF[1]=0:RF[2]=0:RF[3]=0:RF[4]=0:RF[5]=0
            While !GPIO.1:Wend		'wait rising edge	
            TMR0=0	                        'clear TMR0
            While GPIO.1:Wend               'wait falling edge
            sof=TMR0		        'read TMR0
            If (sof<29) Then init		'1920µS
            If (sof>145) Then init		'9280µS
            OPTION_REG=%10000011            'TMR0 1:16 prescaler
            While !GPIO.1:Wend		'wait rising edge
            TMR0=0                          'clear TMR0	        	
            i=0
            Repeat
              While GPIO.1                  'wait falling edge
    	    If TMR0>155 Then break  	'2480µS  
              Wend				'falling edge
              While !GPIO.1                 'wait rising edge
    	    If TMR0>155 Then break  	'2480µS  
              Wend				'rising edge       
              Period=TMR0:TMR0=0            'clear TMR0
              If (period<49) Then init	'800µS
              If (period>93) Then		'1500µS		
                RF.0(i)=1				
              EndIf
              i=i+1
            Until (i>47)
    break:  If (i<12) Then init
            bytes=i/8
            If i//8 Then
    	  bytes=bytes+1
            EndIf
            x=i:GoSub sendhx
            For i = 0 to bytes-1
              x=RF[i]:GoSub sendhx
            Next 
            Debug 13,10
            GoTo init
            
    sendhx: Debug "$"
            If x>>4<10 Then
              Debug x>>4+48
            Else  
              Debug x>>4+55
            EndIf
            if x//16<10 Then  
              Debug x//16+48
            Else    
              Debug x//16+55
            EndIf
            Return
    
            End
    12F509
    Code:
    '=======================| RF RECEIVER |=========================
    'MR26X509.BAS
    'PIC12F509 @ 4MHz          654 words		uses MPASM
    
    'Pin 1 - Vdd
    'Pin 2 - GPIO.5
    'Pin 3 - GPIO.4
    'Pin 4 - GPIO.3
    'Pin 5 - GPIO.2 RS232 output @ 9600bps
    'Pin 6 - GPIO.1 Receives up to 48 bits of PDM/PWM RF with lead-in of 2-9mS
    'Pin 7 - GPIO.0
    'Pin 8 - Vss
    
    'TMR0 1:64 29=1.9mS,145=9.3mS - 1:16 49=0.8mS,93=1.5ms,155=2.5ms
    '===============================================================
    
    @ __config _IntRC_OSC & _WDT_OFF & _MCLRE_OFF & _CP_OFF
    
    DEFINE OSCCAL_1K 1 
    DEFINE OSC 4
    DEFINE DEBUG_REG GPIO
    DEFINE DEBUG_BIT 2 				
    DEFINE DEBUG_MODE 1 				
    DEFINE DEBUG_BAUD 9600	
    
    RF      VAR 	byte[6]
    i       VAR 	byte  
    period  VAR     byte
    bytes	VAR	byte           	
    sof  	VAR 	byte
    x       VAR     byte
    	
    	OPTION_REG=%11000101		'TMR0 1:64 prescaler, disable TOCKI
            TRISIO=%111101                 
            GPIO=%000000
            Debug "MR26X",13,10
            Debug "Copyright ",169," 2009 dlh",13,10
    
    init:	RF[0]=0:RF[1]=0:RF[2]=0:RF[3]=0:RF[4]=0:RF[5]=0
            While !GPIO.1:Wend		'wait rising edge	
            TMR0=0		                'clear TMR0
            While GPIO.1:Wend               'wait falling edge
            sof=TMR0			'read TMR0
            If (sof<29) Then init		'1920µS
            If (sof>145) Then init		'9280µS
            OPTION_REG=%11000011		'TMR0 1:16 prescaler
            While !GPIO.1:Wend		'wait rising edge
            TMR0=0				'reset TMR0
            i=0
            Repeat
              While GPIO.1                  'wait falling edge
    	    If TMR0>155 Then break  	'2480µS  
              Wend				'falling edge
              While !GPIO.1                 'wait rising edge
    	    If TMR0>155 Then break  	'2480µS  
              Wend				'rising edge       
              Period=TMR0:TMR0=0            'clear TMR0
              If (period<49) Then init	'800µS
              If (period>93) Then		'1500µS		
                RF.0(i)=1				
              EndIf
              i=i+1
            Until (i>47)
    break:  If (i<12) Then init
            bytes=i/8
            If i//8 Then
    	  bytes=bytes+1
            EndIf
            x=i:GoSub sendhx
            For i = 0 to bytes-1
      	  x=RF[i]:GoSub sendhx
            Next
            'Debug 32
            'x=sof:GoSub sendhx 
            Debug 13,10
            GoTo init
            
    sendhx: Debug "$"
            If x>>4<10 Then
              Debug x>>4+48
            Else  
              Debug x>>4+55
            EndIf
            if x//16<10 Then  
              Debug x//16+48
            Else    
              Debug x//16+55
            EndIf
            Return
            
            End

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    You have GPIO.1 set as an output with TRISIO=%111101.

    Also, you don't need the DEFINE OSCCAL_1K 1 for 12-bit core parts. PBP automatically
    loads the factory OSCCAL value at power-up.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    You have GPIO.1 set as an output with TRISIO=%111101.
    That was it. Thanks, Bruce.

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. PICBasic newbie problem
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 12th February 2008, 00:55
  3. 12 bit core
    By Ruben Pena in forum mel PIC BASIC
    Replies: 4
    Last Post: - 6th December 2007, 18:04
  4. Real Time Clock & Eeprom
    By smart_storm in forum General
    Replies: 8
    Last Post: - 17th February 2006, 19:03
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

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