FORUM

Using PIC16F877A Set SX1262 register issues

Hello, I am a beginner of SX1262.

I am using assembly language in my program.

I am using the SPI protocol of PIC16F877A to set up the Semtech SX1262 chip (LAMBDA62C-9S RF module). Currently, I have encountered a problem setting the SX1262’s SetStandby mode to STDBY_XOSC. Although I used the GetStatus command to check the current status of the RF IC, the IC status always shows STDBY_RC (as shown in Figure 2), and I still cannot find a solution.

Question 1: Is the opcode and parameter not written correctly to the RF IC?
Question 2: Is the Tx Operation sequence introduced in the datasheet correct?
Question 3: If I want to use FSK mode for wireless transmission, what is the register setting order? Is there anything to pay attention to?

RF IC status: Figure 1
Oscilloscope display: Figure 2

I am using assembly language in my program.

assembly language code:

list p=16F877A
#include <p16f877A.inc>
__CONFIG _FOSC_HS & _WDTE_OFF & _PWRTE_OFF & _BOREN_OFF & _LVP_OFF & _CPD_OFF & _WRT_OFF & _CP_OFF

#define SS PORTC,6
;-------------------
VAL_US equ .146 ;
VAL_MS equ .250 ;
VAL_S equ .4
;
;****************
;--------------
constant equ 0x20
constant_ms equ 0x21
constant_s equ 0x22
constant_any_ms equ 0x23
constant_120us equ 0x24
rfic_Status equ 0x25

;
;****************
;
org 0x00
nop
goto START
;
;************
initial: ;PIC16f877a initial
banksel TRISC
bcf TRISC,3 ;SCK pin as output
bsf TRISC,4 ;SDI pin as input(MISO)
bcf TRISC,5 ;SDO is output(MOSI)
bcf TRISC,6 ;SS pin as output
banksel SSPCON
movlw B’00100010’ ;5.SSPEN=1, 4.CKP =0, 3-0.SPI Master mode, clock = Fosc/64
movwf SSPCON
banksel SSPSTAT
movlw B’00000000’ ;7.SMP=0, 6.SCK( CKE = 0)
movwf SSPSTAT
return

START:
call initial
call power_on_reset
call SetStandby_xosc
call delay_100us
loop:
call GetStatus
goto loop

;--------------
power_on_reset:
bcf PORTA,2
call delay_100us
bsf PORTA,2
return
;
;--------------
SetStandby_rc:
banksel PORTC
bcf PORTC,6 ;nSEL low
movlw 0x80
movwf SSPBUF
call SPI_OUT
movlw 0x00
movwf SSPBUF
call SPI_OUT
bsf PORTC,6 ;nSEL high
return
;--------------
SetStandby_xosc:
banksel PORTC ;bank0
bcf PORTC,6 ;nSEL low
movlw 0x80 ;Opcode
movwf SSPBUF
call SPI_OUT
movlw 0x01
movwf SSPBUF
call SPI_OUT
bsf PORTC,6 ;nSEL high
return
;--------------
SPI_OUT: ;Move data to the MISO of the RFIC
btfss PIR1,SSPIF
goto SPI_OUT
bcf PIR1, SSPIF
return
;--------------
GetStatus:
banksel PORTC
bcf PORTC,6 ;nSEL low
movlw 0xC0 ;Opcode
movwf SSPBUF
call SPI_OUT
movlw 0x00 ;NOP
movwf SSPBUF
call SPI_OUT
call read_Status
banksel PORTC
bsf PORTC,6 ;nSEL high
return
;--------------
read_Status: ;Move Status to rfic_Status
banksel SSPSTAT

read_Status_loop:

btfss SSPSTAT,BF ;Has data been received(transmit complete)?
goto read_Status_loop ;no
banksel SSPBUF
MOVF SSPBUF, W ;WREG reg = contents of SSPBUF
movwf rfic_Status ;Save in user RAM
banksel SSPSTAT
bcf SSPSTAT,BF
return

;--------------5us delay--------------
D_short:
call D_ret ;4ins
call D_ret ;4ins
nop ;1ins
nop ;1ins
D_ret:
return ;2ins,total=12ins=4.8us(10MHz)
;--------------delay_100us--------------
delay_100us: ;103.2us
movlw .15
movwf constant_100us
delay_100us_loop:
call D_short ;2+12
decfsz constant_100us,f ;1 or 2
goto delay_100us_loop ;2
return
;--------------any_ms delay--------------
delay_any_ms:
movwf constant_any_ms ;1
loop_any_ms:
call delay_1ms ;2500+2
decfsz constant_any_ms,f ;1 or 2
goto loop_any_ms ;2
return ;2
;-------- 1 ms delay routine -----------
delay_1ms:
nop ;1
movlw VAL_US ;1
movwf constant ;1
dec_loop: call D_short ;12+2
decfsz constant,f ;1 or 2
goto dec_loop ;2
call D_short ;14
return ;total=3+{(17)145}+(14+2+14+2)=2500ins=1000us
;-------- 250 ms delay routine ----------
delay_250ms: ;total=626,256ins=626,256
0.4us=250502.4us=250ms
movlw VAL_MS
movwf constant_ms
loop_ms:
call delay_1ms
decfsz constant_ms,f
goto loop_ms
return
;-------- 1s delay routine ----------
delay_1s: ;total=2505041ins=2505041*0.4us=1,002,016us=1s
movlw VAL_S
movwf constant_s
loop_s:
call delay_250ms
decfsz constant_s,f
goto loop_s
return

;

END