rfPIC Serin problem


Closed Thread
Results 1 to 40 of 53

Hybrid View

  1. #1
    Join Date
    Nov 2007
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    from the demo program, they used ASK modulation which use NRZ format modulation.
    in this format, when the input is zero it would give you a pulse of 110 while if the input is one, it would give pulse 011, which means it will still give you pulse high for whichever input.

  2. #2
    Join Date
    Nov 2007
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    im still experiencing this overflow stack error message..
    ive tried to change all goto to call instruction
    put return for every subroutine..but still it doesnot work
    can anyone help me

    i pasted my full program below

    Code:
    ;nur azrin hilmi
    ;gdp 17-telemetr 
    
    
        LIST   		P=RF675K       ; list directive to define processor
     	#include    <RF675K.INC>  ; processor specific variable definitions
    
    
    ;**************define variables*********************************
    
    	#define	sensor	GPIO, 1
    	#define txd     GPIO, 2             ; (Output) Transmit Data
    	#define pb3     GPIO, 3             ; (Input Only) Push button switch GP3
    	#define pb4     GPIO, 4             ; (Input) Push button switch GP4
    	#define rfena   GPIO, 5             ; (Output) RF Enable
    
     	; GPIO Pins =    xx543210
    ;	#define gptris b'00011011'
    
    	#define TGUARD  d'5'
    	#define exor 	b'00000000'	
    	#define	total d'8'
    ;	#define	rtime d'5'
    ;***************************************************************
    
    	org  0x00
    	goto initialize
    	
    	org  0x004
    	
    	movwf	w_temp
    	swapf	STATUS,W
    	bcf		STATUS, 5		;select bank 0
    	movwf	status_temp		;save status register
    ;***************************************************************
    
    ;	interrupt service routine (ISR)
    ;   interrupt on change on pin of gpio
    
    	movfw	GPIO
    	bcf		INTCON,0
    	
    ;**************************************************************
    
    	swapf	status_temp,w	;set bank into original state
    	movwf	STATUS
    	swapf	w_temp,F
    	swapf	w_temp,W
    	
    	retfie
    
    
    ;***************************************************************
    
    WaitxTE
            movwf   Count2      ; [1]
    
    waitxlp            
            movlw   D'30'       ; [1]
            movwf   Count       ; [1]
    
    wait400lp
          nop                 ; [1]
    
          nop                 ; [1]
        decfsz  Count,F     ; [1]
        goto    wait400lp  ; [2]
    ;                          --------
    ;                         79 x 5 = 395us
    
         decfsz  Count2,F    ; [1]
        goto    waitxlp    ; [2]
    
         retlw   0           ; [2]
    
    ;                       total 2 (call) + W x (395 + 5) + 2 (return)
    ;                       w = 1 -> 406us @4MHz
    ;                       w = 2 -> 806us @4MHz
    ;*************************************************************
    ;initialize pic
    ;*************************************************************
    
    initialize
    
    ;clearing all ports
    	CLRF	nobit
    	CLRF	nobit2
    	clrf	input
    	clrf	store
    	clrf	rotateright
    	clrf	Count
    	clrf	Count2
    	clrf	ltime
    	clrf	rtime
    ;disable global interrupts during initialization
    
    	bcf     INTCON,7
    
    ;calibrating the internal oscillator
    
    ;	bsf     STATUS,5		;select bank 1
    	call	0x3FF
    	movwf	OSCCAL		
    ;	bcf		STATUS,5
    	
    ;turn off the comparator
    	bsf		STATUS,5
    
    	clrf 	ANSEL			; clear ansel register
    	bcf		STATUS,5
    	
    	clrf 	GPIO			; initialize General Purpose Input Output to 0
    		
    ;setting gpio register to the cosrresponding io pin
    	bsf 	STATUS,5
    	
    	bsf		TRISIO,0
    	bsf		TRISIO,1
    	bsf		TRISIO,4
    	bcf		TRISIO,2
    	bCf		TRISIO,5
    
    	bcf     STATUS,5		;select bank 0
    
    ;set bit 0:2 at register cmcon	;setting gp2 as digital output |offkan comparator
    	bsf		STATUS,5
    	bsf		CMCON,0
    	bsf		CMCON,1
    	bsf		CMCON,2
    	BCF		STATUS,5
    ; VRCON	register ; CVref circuit powered down,no Idd drain
    
    	bsf		STATUS,5
    	bcf		VRCON, 7
    	bcf		STATUS,5
    
    
    ;****************************************************************
    ;****timer1 module gate control**********************************
    ; disabling timer1
    	bsf		STATUS, 5		; select Bank 1
    	movlw   b'01000100'		; disable TIMER1
    	movwf	T1CON		;
    	bcf		STATUS, 5		; select Bank 0
    
    ;****************************************************************
    ;weak pull-up register (wpu)
    ;each pull-up is automatically turned off when the pin is configured as an output
    	bsf     STATUS,5
    	movlw	b'00010000'
    	movwf	WPU
    	bcf     STATUS,5
    
    ;***************set pin for config_address regsiter
    
    ;OPTION Register 
    
    ;   OPTION_REG contains control bits to configure:
    ;   Weak pull-ups on GPIO (see also WPU Register above)
    ;   External GP2/INT interrupt
    ;   TMR0
    ;   TMR0/WDT prescaler
    
            bsf     STATUS,5	         	; ---- Select Bank 1 -----
    
            bcf     OPTION_REG, NOT_GPPU  	; GPIO pull-ups: enabled
    
            bsf     OPTION_REG, INTEDG  	; Interrupt Edge: on rising edge of GP2/INT pin
    
            bcf     OPTION_REG, T0CS    	; TMR0 Clock Source: internal instruction cycle (CLKOUT)
            bcf     OPTION_REG, T0SE    	; TMR0 Source Edge: increment low-to-high transition on GP2/T0CKI pin
    
            bcf     OPTION_REG, 3     		; Prescaler Assignment: assigned to TIMER0
    
            ; TMR0 Prescaler Rate: 1:2
            bcf     OPTION_REG, 2     		; Prescaler Rate Select bit 2
            bcf     OPTION_REG, 1     		; Prescaler Rate Select bit 1
            bcf     OPTION_REG, 0     		; Prescaler Rate Select bit 0
    
            bcf    STATUS, 5         		; ---- Select Bank 0 -----
    
    
    
    
    ;***************************************************************
    ;interrupt on-change register
    	bsf     STATUS,5
    	
    	movlw  	b'00011011'		;enable global interrupts in order for the individual pin to be configured(kalo switch
    	movwf	IOC
    
    	movlw	b'00000000'		;peripheral interrupt register; disable
    	movwf 	PIE1			
    
    	bcf    STATUS,5
    
    	movlw	b'00001000'		;enable interrupt control register 
    	movwf	INTCON
    	
    
    ;******************************************************************
    ;MAIN PROGRAM
    ;*****************************************************************8
    MAIN
    
                  
            bsf     INTCON,7  ; enable global interrupts
    	;	bsf		rfena     ; enable	transmitter
    		call    BITCHECK
    		
    ;*****************************************************************
    ;CHECK INPUT
    ;*****************************************************************
    
    	
    BITCHECK
    	btfsc	nobit2,3 
    	goto	TRANSMIT
    	
    	movfw	GPIO
    	movwf	input	
    	incf	nobit2,f
    	movfw	nobit2
    	movwf	nobit
    
    	
    	btfsc	nobit2,2
    	goto	checkleft	;for bit number 4,5,6,7
    	goto	checkright	;for bit number 1,2,3,8
    
    
    checkleft
    
    	btfsc	nobit2,1
    	goto	rleft
    	btfsc	nobit2,0
    	goto	bit5
    	goto	rright1
    	return;
    checkright
    	btfsc	nobit2,3
    	goto	rleft
    	return;
    rright1
    	movlw	d'5'
    	movwf	rtime
    	return;
    rright
    	
    	decf	rtime,f
    	decfsz	nobit
    	goto	rright
    ;	movwf	rtime
    rotater
    	rrf		input,f
    	decfsz	rtime
    	goto	rotater
    	movfw	input	
    	xorwf	store,w
    	movwf	store
    	goto    BITCHECK
    	return;
    bit5
    	movfw	input
    	xorwf	store,w
    	movwf	store
    	goto	BITCHECK
    	return;
    rleft
    
    	movfw	nobit
    	movwf	ltime
    	decf	ltime
    	decf	ltime
    	decf	ltime
    	decf	ltime	
    	decf	ltime
    	return
    rotatel
    	rlf		input,f
    
    	decfsz	ltime
    	goto	rotatel	
    	movfw	input	
    	xorwf	store,w
    	movwf	store
    	goto    BITCHECK	
        return;                                   
    TRANSMIT
    		bsf		GPIO,5
    ; send preamble (50% duty cycle)
    Preamble					;send 16 bit
          movlw   d'16'
          movwf   BitCount          ; init number of preamble bits
    
    PreL
            bsf     txd             ; ON
            movlw	1
    		call    WaitxTE           ; delay
            bcf     txd             ; OFF
           	movlw	1
    		call    WaitxTE             ; delay
            decfsz  BitCount,F      ; loop
            goto    PreL
                
    ; sync pause
    
    TXloop      
                    
           movlw d'10'
    	   call    WaitxTE         ; Theader = 10 x Te
                
    ; send 72 bit pattern
    
            movlw   store            ; lsb first 
            movwf   FSR
                
    TXNextByte
          movlw   D'8'
          movwf   BitCount
    
    TXNextBit
    		
            rrf     INDF,W           ; 8 bit rotate | rotate right f through carry
            rrf     INDF,F           ; Carry contain lsb
            BC      ONE				 ; branch on carry | goto ONE if bit is set
    ZERO    					;wave pattern if the bit is zero        
            movlw   2               ; 
    	    movwf   TimeHi          ;   +---+---+   +--
            movlw   1               ;   |       |   |
       		movwf   TimeLo          ;---+       +---+
            goto    Trasm_BIT       ;   |  2Te   Te |
    
    ONE							;wave pattern if the bit is one
            movlw   1              	;              
            movwf   TimeHi          ;   +---+       +--
            movlw   2               ;   |   |       |
            movwf   TimeLo          ;---+   +---+---+
                                    ;   | Te   2Te  |
    	
    Trasm_BIT
    
            bsf     txd             ; ON
            movf    TimeHi,W          
            call    WaitxTE
    		
            bcf     txd             ; OFF
            movf    TimeLo,W          
            call    WaitxTE
    
           	decfsz  BitCount,F
            goto    TXNextBit       ; loop on bits
    
       
    ; guard time
            movlw   TGUARD
            call    WaitxTE
    
           org     0x3ff
           retlw    0x80
    
    	
    ;----------------------------------------------------------------------
            end                         ; end of program directive
    ;----------------------------------------------------------------------

  3. #3
    Join Date
    Nov 2007
    Posts
    9


    Did you find this post helpful? Yes | No

    Default help with pic12f676

    Hi,

    I managed to work through the receiving and process the data and store it to DATA0.
    What I can't do now is sending out serially the 8 bit DATA0 to
    the pin SER_OUT(which happens to be PIN RC0).

    I've tried to copy DATA0 to PORTC (in RECORD2) but since PORTC is only 6 bit, the data is not out correctly. Can anyone help me please?

    ;----------------------------------------
    ; RECORD
    ; Records each bit as it comes in from the data stream.
    ;
    ; Input Variables:
    ; RXDATA
    ; Output Variables: 1 bytes of the 8 bit data read from sensor
    ; DATA0

    RECORD
    movf HIGHWDTH, W
    subwf LOWWDTH, W ; The state of the carry bit after
    ; this operation reflects the data
    ; logic. This is then rotated
    ; into the storage bytes.
    rrf DATA0, F ; the only data to be processed
    movlw HIGHP ; 0x04 to STATECNTR
    movwf STATECNTR
    decfsz BITCNTR, F ; If the bitcntr is = 0 , skip next instruction
    goto MAIN
    ; set to count for 1 data - record 1 byte of data bit by bit
    movlw D'1' ; Starting here and including RECORD1
    movwf COUNTR ; a check is made to make sure that

    movlw DATA0 ; the data is not composed entirely
    movwf FSR ; of 1s.
    ;FSR is the register to store the DATA0
    RECORD1 ; this is the procedure of indirect addressing
    movlw 0xFF
    xorwf INDF, W ; Use indirect referencing to point to
    btfss STATUS, Z ; DATA0 on subsequent loops
    goto RECORD2 ; in RECORD1.

    incf FSR, F
    decfsz COUNTR, F
    goto RECORD1

    goto RESTART

    RECORD2
    movlw WAIT
    movwf STATECNTR ; Make state WAIT4END

    movfw DATA0 ; copy DATA0 to PORTC
    movwf PORTC ; want to send data out serially

    ; bsf SER_OUT ; pin RC5 to observe the processed output

    goto MAIN

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    medusa2584,
    Recheck your code flow.
    You're still trying to RETURN from GOTO in various places.
    And (I'm not even sure if it's possible in MPLAB) are you getting stack OVERFLOW errors or stack UNDERFLOW errors? If getting UNDERFLOW is possible, that's what I'd say you're getting.

  5. #5
    Join Date
    Nov 2007
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    thanks skimask. i solved the the underflow and overflow program. however, i got a new problem.

    when i tested my program with rfpic12f675, and put probe at gp2 and gp5. the output is similar with what i simulated in mplab sim. there is preamble, header, and data bits. however, there is no change of output displayed on the oscilloscope even i dont supply any input to the transmitter. any suggestion why this happened?

    the output always showed data bit of 1111 0111 which is weird since i sont supply any input to the system.

    any suggestion anyone?

  6. #6
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    medusa2584,
    Recheck your code flow.
    You're still trying to RETURN from GOTO in various places.
    And (I'm not even sure if it's possible in MPLAB) are you getting stack OVERFLOW errors or stack UNDERFLOW errors? If getting UNDERFLOW is possible, that's what I'd say you're getting.
    Hello skimask,

    I'd like to take this opportunity to welcome you back to the forum. I do hope that your stay will be a long, pleasant & fruitful one. Everyone deserves a second chance

  7. #7
    Join Date
    Nov 2007
    Posts
    9


    Did you find this post helpful? Yes | No

    Default

    Hi,

    I was simulating my program and did not even finish running everything - my MPlab just suddenly close itself with a window Microsoft is checking the problem.

    Does anyone know why? Is that because of my Vista or because of the bug in the
    new version MPLab IDe 8?

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


    Did you find this post helpful? Yes | No

    Default

    Check out the Microchip forum, i remember to have already heard about some strange problem using Vista.
    http://forum.microchip.com/tt.aspx?forumid=57

    PS: you have 'till January to buy an XP o/s... to me, Vista is really not recommended before, at very least, 1 year...
    Steve

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

  9. #9
    Join Date
    Nov 2007
    Posts
    9


    Did you find this post helpful? Yes | No

    Default

    I suppose that might be the problem. I'll try simulating that on XP based first then.

    I need some help with understanding the rate of data in programming the receiver rfrxd420 using pic16f676.

    The demo program currently indicates that the the TMRHIGH and TMRLOW to be multiply with 4us. Does this relates to the baud rate?
    I'm having problem to understand the timing of the program.
    Can anyone help?

  10. #10
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by T.Jackson View Post
    Hello skimask,
    I'd like to take this opportunity to welcome you back to the forum. I do hope that your stay will be a long, pleasant & fruitful one. Everyone deserves a second chance
    2nd chance?
    2nd chance at what?
    Did I lose my first chance at something?
    Did you have something to do with afford me a second chance at whatever it is?
    Did I go somewhere else that I needed to come back?

  11. #11
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Howdy skimask, good to hear from you again.
    Dave
    Always wear safety glasses while programming.

  12. #12
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    2nd chance?
    2nd chance at what?
    Did I lose my first chance at something?
    Did you have something to do with afford me a second chance at whatever it is?
    Did I go somewhere else that I needed to come back?
    I see that someone is experiencing some considerable "self-denial".

  13. #13
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by T.Jackson View Post
    I see that someone is experiencing some considerable "self-denial".
    Time for someone else to step outside and play a one-handed game of hide and go @$%&# one's self...and deny some of that...

Similar Threads

  1. Serin Problem with 12F629/PBP
    By Flyingms in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 9th March 2009, 14:59
  2. Serin Problem 16f819
    By jjohannson in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd March 2007, 22:50
  3. Serin serout problem
    By lerameur in forum mel PIC BASIC Pro
    Replies: 336
    Last Post: - 6th February 2007, 04:25
  4. Problem with PBP interrupt and Serin, please help
    By rgregor in forum mel PIC BASIC
    Replies: 0
    Last Post: - 22nd August 2006, 19:02
  5. serout and serin problem
    By nicolelawsc in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th April 2006, 19:44

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