Continue to Site

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.

  • 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.

Converting Arduino to Oshonsoft.

Status
Not open for further replies.

camerart

Well-Known Member
Hi,

I assume that Arduino is written in 'C' is this correct?

If I see a line: shiftin sdo, sck, 0,(nindata) What would the equivalent be in Oshonsoft Basic? Also for OUT please?

Camerart.
 
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
 
hi C,

This a clip from a NRF radio program I have written.

On Interrupt
Save System
'interrupt on any Pipe RXD

INTCON.INTF = 0
rxd_led = 1

'RX receive
receive:
SPICSOn
SPISend rd_rx_pload
WaitUs 10

For x = 0 To dta_len
SPIReceive rx_dta(x)
WaitUs 10
Next x


SPICSOff
 
Hi,
Thanks, both.

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.

C.
 
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
    7 KB · Views: 269
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top