Remote control by location (PIC in Oshonsoft)

jjw

Joined Dec 24, 2013
823
Yes.
Periph_wr ( adr, data) writes a byte data to a register which has address adr.
adr, data are the names of the variables ( parameters or arguments) used inside the function.
The names can be anything.
When calling the function, the adr and data are given the actual values needed.
Show how the periph_rd, periph_wr functions look now.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,837
Yes.
Periph_wr ( adr, data) writes a byte data to a register which address is adr.
adr, data are the names of the variables ( parameters or arguments) used inside the function.
The names can be anything.
When calling the function, the adr and data are given the actual values needed.
Show how the periph_rd, periph_wr functions look now.
Hi J,
I am fairly sure I understand how it all works, but you added a periph_wr, when I thought we are talking about READing the DATA, this is what's confusing me.

In periph_wr I use wr_adr and in periph_rd I use rd_adr, just for my inderstanding

Is it ok to post the whole working program?
C.
 

jjw

Joined Dec 24, 2013
823
Ok, but it would better to test first, that the periph functions work.
Try to read for example the ID
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,837
It is the compass ID.
I thought you are working now on BMP280.
Hi J,
Yes, it is the compass.
The reason I asked for help was the way I am working at the moment, doesn't allow more than 1x peripheral. If I'm not mistaken, how you suggest will READ many peripherals.
C
 

jjw

Joined Dec 24, 2013
823
What is the problem with C/S?
You chip select compass on,
do compass programs, setup, read / write values etc.
select compass off.

select bmp280 on .....
do things
.....
select bmp280 off

All these using the same periph_rd and periph_wr functions.
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,837
What is the problem with C/S?
You chip select compass on,
do compass programs, setup, read / write values etc.
select compass off.

select bmp280 on .....
do things
.....
select bmp280 off

All these using the same periph_rd and periph_wr functions.
Hi J,
Yes, it's seems so easy, till I try.
I tried for weeks, but never got 2x pripherals to work.
I'll have to go back and find a near to working program, and start from there.
C
 

jjw

Joined Dec 24, 2013
823
I mean that, if you make the periph_rd, periph_wr functions, you can use the old working BMP280 program, which uses Oshonsofts SPI functions replacing them with periph functions almost with editors search and replace with some manual work.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,837
I mean that, if you make the periph_rd, periph_wr functions, you can use the old working BMP280 program, which uses Oshonsofts SPI functions replacing them with periph functions almost with editors search and replace with some manual work.
Hi J,
I think you suggested that previously, which I followed, and almost got it working, but never properly.

Perhaps the next thing could be that, after getting the compass to work, I'll try to get BMP280 to work by itself, then try again to get both to work.
C
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,837
Hi J,
I started to set up for READing ALTMTR instead of COMPSS, and realised that obviously the C/S was set for COMPSS, but for the SPI to show in the digital analyser it needed to be changed to ALTMTR_CS. All this is pretty obvious really, but I've only just figured it out.
Anyway, now the D/A is showing results from ALTMTR. I can see things that need changing to follow the D/S, which I've tried before, but didn't get results, due to the above.
I hope this makes sense.

Now let's see if I can get the ALTMTR working.
C
 

Thread Starter

camerart

Joined Feb 25, 2013
3,837
Hi J,
I'm trying to use the CODE you sent in #997.

What does the WR line do in this?:
C

For example: read from BMP280 address 0xf7
altmeter_cs=0'// this can be for example Symbol altmeter_cs = LATX.0
data= periph_rd( 0xf7)
.....
periph_wr( wr_adr,data)

EDIT: I think there's something wrong with the FUNCTIONS (Previously). I think the RED line is for putting the register to be READ into the peripheral, then READ it using PERIPH_RD. On one hand this looks correct, but I think the register e,g, ADR 0XF7 should be written into the PERIPH_RD, not PERIPH_WR as shown.
 
Last edited:

jjw

Joined Dec 24, 2013
823
Hi J,
I'm trying to use the CODE you sent in #997.

What does the WR line do in this?:
C

For example: read from BMP280 address 0xf7
altmeter_cs=0'// this can be for example Symbol altmeter_cs = LATX.0
data= periph_rd( 0xf7)
.....
periph_wr( wr_adr,data)

EDIT: I think there's something wrong with the FUNCTIONS (Previously). I think the RED line is for putting the register to be READ into the peripheral, then READ it using PERIPH_RD. On one hand this looks correct, but I think the register e,g, ADR 0XF7 should be written into the PERIPH_RD, not PERIPH_WR as shown.
No, I don't understand.
data= periph_rd( 0xf7) reads from peripherals register address to a variable named data.
The red line periph_wr( wr_adr, data) writes data to peripheral address wr_adr.
The data which is written is to set the peripherals various settings.

With the HW SPI functions this can be done with one single command.
Maybe you remember Oshonsofts SW SPI functions, where
two lines of code was needed, like
SPISend adr
SPIReceive data
or
SPISend adr
SPISend data
 

Thread Starter

camerart

Joined Feb 25, 2013
3,837
No, I don't understand.
data= periph_rd( 0xf7) reads from peripherals register address to a variable named data.
The red line periph_wr( wr_adr, data) writes data to peripheral address wr_adr.
The data which is written is to set the peripherals various settings.

With the HW SPI functions this can be done with one single command.
Maybe you remember Oshonsofts SW SPI functions, where
two lines of code was needed, like
SPISend adr
SPIReceive data
or
SPISend adr
SPISend data
Hi J,
I think I now know where the misunderstandings are!

1/ A penny dropped deciding whether these are PROCEDUREs or FUNCTIONs. As a FUNCTION returns a value, I'm going to use these for READing and PROCEDUREs for WRITING.

2/ The PERIPH_WR PROCEDURE is only for setting the registers earlier in the program before READ.
The PERIPH_RD FUNCTION is for READing the registers e,g, the ID, and RAW data, so should have the ARGUMENT the register address to be READ e,g, 0XF7, and the FUNCTION will the RESULT.

When I change this, the Compass will stop working (Temporarily), as it will be out of date. I'll use your post #997 for this.

Hopefully, this is all correct, or let me know please.
C
 
Last edited:

jjw

Joined Dec 24, 2013
823
I can't test these HW SPI functions or procedures, but the functions may also work for writing, you just don't need to give the return value to a function?
 

Thread Starter

camerart

Joined Feb 25, 2013
3,837
I can't test these HW SPI functions or procedures, but the functions may also work for writing, you just don't need to give the return value to a function?
Hi J,
Perhaps it's best for me to use them as I outlined #1018 (Is it really so many!) till I get more proficient.

Any CODE you post I can run it through my set up.
C
 
Top