Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
Arduino's primary language is C++.. This is basically a software serial read.. Oshonsoft hasn't this function but you could use the software SPI to do this...
hi C,
This modified example is from the OSH manual
The BOLD character block is a read input.
E
Example 1:
AllDigital
Define SPI_CS_REG = PORTC
Define SPI_CS_BIT = 0
Define SPI_SCK_REG = PORTC
Define SPI_SCK_BIT = 3
Define SPI_SDI_REG = PORTC
Define SPI_SDI_BIT = 4
Define SPI_SDO_REG = PORTC
Define SPI_SDO_BIT = 5
SPIPrepare
Dim addr As Byte
Dim data As Byte
For addr = 0 To 10
data = 200 - addr
SPICSOn
SPISend 0x06
SPICSOff
SPICSOn
SPISend 0x02
SPISend addr
SPISend data
SPICSOff
WaitMs 500
Next addr
For addr = 0 To 10
SPICSOn
SPISend 0x03
SPISend addr
SPIReceive data
SPICSOff
WaitMs 500
Next addr
I've placed the above code into my program and there are pins ON/OFFing. Thanks.
I'm trying to program an 18F4520 to fill a RFM radio module registers, as set in the Data sheet, then a LOOP to use the RFM by sending/receiving DATA.
The Register data looks like this:
'Clk output is 2 MHz
naddress = $0a
noutdata = $05
Gosub spi_out
'GPIO0 is RX data output
naddress = $0b
noutdata = $f4
And the sending/receiving DATA could be an NMEA sentence for example.
hi C
This is an example of how I write to radio by SPI
E
SPICSOn
SPISend rx_pw_p1 '0x32 this is the address of the reg you want to write too.
WaitUs 10
SPISend dta_len ' this is the data that will be written to that address
SPICSOff
WaitUs 20
So yours:
The Register data looks like this:
'Clk output is 2 MHz
naddress = $0a
noutdata = $05
Gosub spi_out
'GPIO0 is RX data output
naddress = $0b
noutdata = $f4
becomes:
SPICSOn
SPISend $0a this is the address of the reg you want to write too.
WaitUs 10
SPISend $05' this is the data that will be written to that address
SPICSOff
WaitUs 20
SPICSOn
SPISend $0b this is the address of the reg you want to write too.
WaitUs 10
SPISend $f4' this is the data that will be written to that address
SPICSOff
WaitUs 20
Hi,
Here's a snippet of code that's been sent to me: Can it be made to work in Oshonsoft, or is my attached code as good? Mine compiles in SIM ok. It's for loading registers for radio module set-up.
C.
Write(RegOpMode, 0x00); //Putting RADIO to sleep
Write(RegOpMode, 0x80); //Switch to LoRa mode
Write(RegOpMode, 0x81); //Setting RADIO to standby
while (digitalRead(DIO5) == LOW) //Wait for mode ready
{
}
--Now it is time to make your register settings here--
--And now we leave standby.
Code: [Select]
Write(RegOpMode, 0x85); //Set RADIO to continuous receive
while (digitalRead(DIO5) == LOW) //Wait for mode ready
{
}
EDIT:D105 refers to a PIN on the radio module.
Attachments
18F4520 32MHz INT Button ON TX OFF RX 211016 1000.txt
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.