View previous topic :: View next topic |
Author |
Message |
Vincent
Joined: 25 Jun 2012 Posts: 69
|
Posted: Tue Jul 31, 2012 10:49 am Post subject: Can someone help me with the Microchip MRF49XA |
|
|
Hi everybody.
I tried too use the MRF49XA since a lot of days. Know my MRF49XA is OK to emitter, but to receive and with the fifo, really I don't know why it doesn't work.
Please have you a link or programm sample with this device ?
Have you already use with good result this MRF49XA
Really thanks if you can help me.
Best regards
|
|
Back to top |
|
|
MAK3
Joined: 24 Sep 2010 Posts: 449 Location: Germany
|
|
Back to top |
|
|
MAK3
Joined: 24 Sep 2010 Posts: 449 Location: Germany
|
|
Back to top |
|
|
Dave
Joined: 05 Feb 2005 Posts: 314 Location: OR
|
|
Back to top |
|
|
MAK3
Joined: 24 Sep 2010 Posts: 449 Location: Germany
|
|
Back to top |
|
|
Dave
Joined: 05 Feb 2005 Posts: 314 Location: OR
|
Posted: Tue Jul 31, 2012 7:08 pm Post subject: |
|
|
MAK3 - Thanks again, I knew about that one. When it comes to RFM12Bs we need all the help we can get. - Dave |
|
Back to top |
|
|
Vincent
Joined: 25 Jun 2012 Posts: 69
|
Posted: Wed Aug 01, 2012 4:14 pm Post subject: |
|
|
Hi,
Thanks for this link , I have read the sample, and probe to run the fifo, .... but now it always doesn't work. But courage and I don't stop to search why my fifo don't recognized the synch pattern etc ...
Thanks for all
Regards
Vincent |
|
Back to top |
|
|
concon
Joined: 12 Nov 2011 Posts: 3
|
Posted: Wed Aug 01, 2012 4:41 pm Post subject: mrf89xa |
|
|
Hi,
I want to use mrf89xa replacing mrf49ax. is this possible ? |
|
Back to top |
|
|
Vincent
Joined: 25 Jun 2012 Posts: 69
|
Posted: Thu Aug 02, 2012 2:33 pm Post subject: |
|
|
Hi everybody,
please can you see my code and say me what is wrong and why my fifo doesn't work.
The emitter send &HAA
&H2D
&HD4
&H08 <----length (8bits)
Compter (1,2,3 ....255)
and here the receiver ... but not working
(Excuse me I don't know how send my code in the forum correctly. I put "Code tags" but the code is not written correctly.)
Code: |
$PROG &HFF , &HE2 , &HDF , &HF9 ' generated. Take care that the chip supports all fuse bytes.
$regfile = "m88pdef.dat"
$crystal = 8000000
$hwstack = 40
$swstack = 40
$framesize = 128
'--------------------------------------CONFIGURATION DES VARIABLES----------------------------------------------------------------
'dim operation as Byte
'dim instruction as Byte
dim GENCREG1 as Byte
dim GENCREG2 as Byte
dim AFCCREG1 as Byte
dim AFCCREG2 as Byte
dim TXCREG1 as Byte
dim TXCREG2 as Byte
dim TXBREG1 as Byte
dim TXBREG2 as Byte
dim CFSREG1 as Byte
dim CFSREG2 as Byte
dim RXCREG1 as Byte
dim RXCREG2 as Byte
dim BBFCREG1 as Byte
dim BBFCREG2 as Byte
dim RXFIFOREG1 as Byte
dim RXFIFOREG2 as Byte
dim FIFORSTREG1 as Byte
dim FIFORSTREG2 as Byte
dim SYNBREG1 as Byte
dim SYNBREG2 as Byte
dim DRSREG1 as Byte
dim DRSREG2 as Byte
dim PMCREG1 as Byte
dim PMCREG2 as Byte
dim BCSREG1 as Byte
dim BCSREG2 as Byte
dim PLLCREG1 as Byte
dim PLLCREG2 as Byte
dim STATUSREG as Byte
dim Byte1 as Byte
dim Byte2 as Byte
dim commande as Byte
dim A as Byte
dim B as Byte
dim D as Byte
dim E as Byte
dim F as byte
Dim TX_ON as byte
TX_ON = pmcreg2 or &h20
Dim RX_ON as Byte
RX_ON = pmcreg2 or &h80
Dim long_packet as Byte
dim nbr_byte as Byte
'------------------------------CONFIGURATION DES CONSTANTES-------------------------------
GENCREG1 = &H80 'ok
GENCREG2 = &H38
AFCCREG1 = &HC4 'ok
AFCCREG2 = &HD7
TXCREG1 = &H98 'ok
TXCREG2 = &H30
TXBREG1 = &HB8 'ok
TXBREG2 = &H00
CFSREG1 = &HA7 'ok
CFSREG2 = &HD0
RXCREG1 = &H94 '&H90 'ok
RXCREG2 = &HA1 '&H80
BBFCREG1 = &HC2 'ok
BBFCREG2 = &H2C
RXFIFOREG1 = &HB0
RXFIFOREG2 = &H00
FIFORSTREG1 = &HCA 'ok
FIFORSTREG2 = &H81 '&H83
'SYNBREG1 = &HCE
'SYNBREG2 = &HD4
DRSREG1 = &HC6 'ok
DRSREG2 = &H82
PMCREG1 = &H82 'ok
PMCREG2 = &H00
'BCSREG1 = &HC0
'BCSREG2 = &H00
'PLLCREG1 = &HCC
'PLLCREG2 = &H77
STATUSREG = &H00
config portC.0 = output
CS alias portC.0
portC.0 = 1
config portC.1 = output
led1 alias portC.1
config portC.2 = output
led2 alias portC.2
config portb.1 = output
FSK alias portb.1
FSK = 1
menu alias pinC.4
config menu = input
action alias pinC.5
config action = input
dim ordreHF(6) as Byte
ordreHF(1) = TXBREG1
ordreHF(2) = &HAA
ordreHF(3) = TXBREG1
ordreHF(4) = &H01
ordreHF(5) = TXBREG1
ordreHF(6) = commande
config pinB.4 = input
RF_SDO alias PINB.4
config portB.1 = output
RF_SEL alias portB.1
'=========================================================================================
' CONFIGURATION DU LCD =
'=========================================================================================
Config Lcdpin = Pin , Db4 = PortD.2 , Db5 = Portd.3 , Db6 = Portd.4 , Db7 = Portd.1 , E = Portd.0 , Rs = Portb.6
Config Lcd = 16 * 2
Config Lcdmode = Port
Config Lcdbus = 4
'----------------------------------------------------------------------------------------
'========================================================================================
' CONFIGURATION DU SPI VERS MRF49XA =
'========================================================================================
'Config Spi = hard , Interrupt = off , data_order = MSB , MASTER = YES , POLARITY = low , PHASE = 1 , CLOCKRATE = 128 , noss = 1
config SPI = SOFT , DIN = PORTB.4 , DOUT = PORTB.3 , CLOCK = PORTB.5 , SS = none , mode = 0
'enable SPI
Spiinit
'----------------------------------------------------------------------------------------
'====================================================================================
'= SEQUENCE D'INITIALISATION DU MRF49XA en emetteur =
'====================================================================================
INIT_MRF49XA:
byte1 = drsreg1
byte2 = drsreg2
gosub ENVOI_SPI
waitms 1
byte1 = fiforstreg1
byte2 = fiforstreg2
gosub ENVOI_SPI
waitms 1
byte1 = fiforstreg1
byte2 = fiforstreg2 or &h02
gosub ENVOI_SPI
Waitms 1
byte1 = gencreg1
byte2 = gencreg2
gosub ENVOI_SPI
Waitms 1
byte1 = cfsreg1
byte2 = cfsreg2
gosub ENVOI_SPI
Waitms 1
byte1 = pmcreg1
byte2 = pmcreg2
gosub ENVOI_SPI
waitms 1
byte1 = RXCREG1
byte2 = RXCREG2
gosub ENVOI_SPI
waitms 1
byte1 = txcreg1
byte2 = txcreg2
gosub ENVOI_SPI
Waitms 1
'ANTENNA TUNNING
byte1 = pmcreg1
byte2 = pmcreg2 or &H20
gosub ENVOI_SPI
waitms 8
'END OF ANTENNA TUNNING
byte1 = pmcreg1
byte2 = pmcreg2 or &H80
gosub ENVOI_SPI
waitms 1
byte1 = gencreg1
byte2 = gencreg2 or &H40
gosub ENVOI_SPI
waitms 1
byte1 = fiforstreg1
byte2 = fiforstreg2
gosub ENVOI_SPI
waitms 1
byte1 = fiforstreg1
byte2 = fiforstreg2 or &h02
gosub ENVOI_SPI
Waitms 1
goto main
'===================================================================================
'= MRF49 RESET RADIO =
'===================================================================================
reset_radio:
byte1 = fiforstreg1
byte2 = fiforstreg2 'or &h02
gosub ENVOI_SPI
Waitms 1
return
'------------------------------------------------------------------------------------
'============================================================================
' ENVOI_SPI =
'============================================================================
ENVOI_SPI:
CS = 0
spiout byte1 , 1
spiout byte2 , 1
CS = 1
return
'------------------------------------------------------------------------------
'===============================================================================
'= AFFICHAGE SUR LCD DES PACKETS RECUS =
'===============================================================================
AFFICH_RECEPTEURLCD:
CLS
locate 1 , 1
LCD "D=" ; d
locate 1 , 7
lcd "E=" ; e
locate 2 , 1
lcd "F=" ; f
waitms 450
return
'----------------------------------------------------------------------------------
gosub AFFICH_RECEPTEURLCD
main:
waitms 10
'cs = 0
'waitus 300
if rf_sdo = 1 then
'cs = 1
rf_sel = 0
cs = 0
spiin d , 1
'cs = 1
'cs = 0
spiin e , 1
'cs = 1
'cs = 0
'spiin f , 1
cs = 1
rf_sel = 1
waitms 10
gosub RESET_RADIO
waitms 10
gosub AFFICH_RECEPTEURLCD
endif
goto main
|
Last edited by Vincent on Mon Aug 06, 2012 7:19 am; edited 2 times in total |
|
Back to top |
|
|
enniom
Joined: 20 Oct 2009 Posts: 537
|
Posted: Sun Aug 05, 2012 5:00 pm Post subject: |
|
|
Hello Vincent,
some observations:
1. in this routine,
Code: | ENVOI_SPI:
CS = 0
spiout byte1 , 1
spiout byte2 , 1
CS = 1
return
|
Rf_sel is not activated - so, I don't think MRF is seeing these commands.
2. Reading the MRF is done with
Code: | If Rf_sdo = 1 Then
Rf_sel = 0
Cs = 0
Spiin D , 1
Spiin E , 1
Cs = 1
Rf_sel = 1
etc. |
I don't understand why the MRF interrupt has not been defined and then used to trigger reading the D and E bytes (What makes Rf_sdo = 1?).
3. FSK and Rf_sel are both on PORTB.1?
4. to make your posted code format correctly in the Forum, edit your last post and remove the second "/code".
Ennio |
|
Back to top |
|
|
Vincent
Joined: 25 Jun 2012 Posts: 69
|
Posted: Mon Aug 06, 2012 7:13 am Post subject: |
|
|
Hi Enniom,
Thanks for reply. For the first routine it is just SPI from µC to the MRF49XA (to configure etc ...) and with this routine is all right. I can configure the MRF with this routine and transmitt what I want.
In the second routine, the RF_sel is the FSK/DATA/FSEL pin on the MRF. The pin RF_sdo is the SDO pin on the MRF,
What I probe is to "hear" with the MRF if the synchronous pattern is ok , then if sdo is high then spiin !!!
I don't understand why I havn't any interrupt to send and to read
Thanks for your help
Vincent |
|
Back to top |
|
|
Vincent
Joined: 25 Jun 2012 Posts: 69
|
Posted: Mon Aug 06, 2012 7:44 am Post subject: |
|
|
hi ennio,
Can you say me how to configure the interrupt on the mrf ? Have you a simple code to send something with 1 MRF49 and receive with another one? with all the config to send with the interrupt in txbreg (to put one byte and wait the interrupt for put the following one) and in the recepter to receive the synchronous caractere pattern, and then put a interrupt one the µC and then read the first byte and wait the interrupt to read the following one etc ?
I try to work with him since a few weeks, and really I have courage, but now it's too difficult, I have read the datasheet and read and read ... but this chip is better as me.
Really thanks for your time and patience.
Regards
Vincent |
|
Back to top |
|
|
enniom
Joined: 20 Oct 2009 Posts: 537
|
Posted: Mon Aug 06, 2012 12:55 pm Post subject: |
|
|
Vincent,
The easiest way to set up an interrupt is using INT0 or INT1 (PORTD.2/3) - see INT0.BAS in BASCOM Sample Folder. But these pins you have used for the LCD. Maybe the LCD pins can be moved?
The next option is to use an open pin that has PCINT capability. Again, look at the BASCOM Samples - they are based on a MEGA88 microcontroller; and search the BASCOM Forum - there are many examples.
Look here http://mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=10004&highlight=pcint&sid=b9d6b4706e42364da788ccc64a2a0a64
Tim has prepared sample code as well.
After your try, post your interrupt code if you still need help.
I am not so familiar with the this MRF but is seems you need to read the STSREG (page 52) then determine which bit set the interrupt (page 19).
Ennio
Last edited by enniom on Mon Aug 06, 2012 1:25 pm; edited 1 time in total |
|
Back to top |
|
|
Vincent
Joined: 25 Jun 2012 Posts: 69
|
Posted: Mon Aug 06, 2012 1:06 pm Post subject: |
|
|
Hi Ennio,
thanks for this reply, I thing that you havn't understand me (excuse me for my bad English)
What I want to know is how can I configure the MRF49xa interrupt. On the MRF the IRO pin don't give me any interrupt. When I send someone in TXBREG I send a lot of byte, but no interrupt from the MRF to say me : " I have receive your byte and it's ok this byte was send now in RF, give me the next byte." Can you understand ?
What is difficult for me is to have a lot of interrupt to send AND to receive byte.
In the FIFO normaly, if I send "&HAA;&H2D;&HD4;&H01(nbr of byte will send);&Hdata" the receiver must recognize the &HAA,&H2D;&HD4 then give me a interrupt to the µC that go to the "SPIIN" routine . This is what I have understand from the datasheet. And I can't have interrupt .
This is because I have ask you if you have a simple code to send someone with the emitter, and a another simple code to receive this in the fifo.
I want to say you really thanks, because I feel me alone with this and can't find some outcome.
Best regards Ennio
Vincent |
|
Back to top |
|
|
enniom
Joined: 20 Oct 2009 Posts: 537
|
Posted: Mon Aug 06, 2012 1:50 pm Post subject: |
|
|
Vincent,
it seems to me that the transmitted data is not being received by the receiver.
The code shows GENCREG = 1000 0000 0011 1000 (&H80, &H38). Bit 6 =1 means FIFO Enabled but note 2 page 21 shows the DATA/FSK/FSEL must be "low".
Is this the case with your recever?
Ennio |
|
Back to top |
|
|
|