Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 12:06 04 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Help Webmite I2C

Author Message
Gerad
Newbie

Joined: 10/01/2024
Location: Germany
Posts: 37
Posted: 12:25pm 23 Apr 2024
Copy link to clipboard 
Print this post

Hello everyone

I'm trying to connect a Webmite and a Picomite (both on the same board) with I2c.
I want to read out the 4 CIN pins of the Picomite

the example (picomite 5.08 page 157) works.
But I would like to carry out the transfer without interrupt.

The example below (page 157) doesn't work.
Error: Invalid configuration

DIM AS INTEGER RData(2) ' this will hold received data
SETPIN GP6, GP5, I2C2 ' assign the I/O pins for I2C2
I2C2 OPEN 100, 1000 ' open the I2C channel
I2C2 WRITE &H51, 0, 1, 3 ' set the first register to 3
I2C2 READ &H51, 0, 2, RData() ' read two registers
I2C2 CLOSE ' close the I2C channel
PRINT "Time is " RData(1) ":" RData(0)

The names I2C2 and I2C confuse me. See example

"SETPIN GP6, GP5, I2C2 ' assign the I/O pins for I2C2"
"I2C2 OPEN 100, 1000 ' open the I2C channel"
"I2C2 CLOSE ' close the I2C channel"

Which channel is used?

My second question:
How is the I2C address generated? Via hardware or software?

After 2 days of try and error, I ask the BackShed Community for help

Gerad
Edited 2024-04-23 22:31 by Gerad
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 3557
Posted: 01:12pm 23 Apr 2024
Copy link to clipboard 
Print this post

All PicoMites (also the webmite) have 2 hardware I2C blocks inside.
These are called I2C and I2C2.
In the pin diagram in the user manual (page 9 for webmite) you can see which hardware block can be assigned the which pins.

But you can write software for 2 independent I2C busses.



Your problem os that GP5 and GP6 belong to different hardware blocks. I suggest you connect the GP5 wire to GP7, change the SETPIN to include GP7 is stead of GP5, then all will be fine.

Regards,

Volhout
Edited 2024-04-23 23:14 by Volhout
PicomiteVGA PETSCII ROBOTS
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8592
Posted: 01:17pm 23 Apr 2024
Copy link to clipboard 
Print this post

  Quote  But I would like to carry out the transfer without interrupt.


You can't. One of them must be an I2C slave and in slave mode it only operates under interrupt control. Only the slave has an address and this is set up in software when the slave open command is executed.
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3017
Posted: 01:21pm 23 Apr 2024
Copy link to clipboard 
Print this post

Try serial instead: https://www.thebackshed.com/forum/ViewTopic.php?FID=16&TID=16862#220194

Good code examples on page 2. The serial comms buffering makes this a breeze in MMBasic.

Communication can be both ways, or client can just send new readings when values change and main 'mite can retrieve them from the serial buffer when it is convenient.

~
Edited 2024-04-23 23:26 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Gerad
Newbie

Joined: 10/01/2024
Location: Germany
Posts: 37
Posted: 08:34pm 23 Apr 2024
Copy link to clipboard 
Print this post

Thank you for your reply

Isn't there a simpler way to transfer 10-20 bytes per day?

Regards
Gerad
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5735
Posted: 09:05pm 23 Apr 2024
Copy link to clipboard 
Print this post

The COM ports are probably the easiest way. No addresses to bother about and just connect TX-RX and RX-TX. I like to put a 220R series resistor in each line just for safety.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3017
Posted: 09:42pm 23 Apr 2024
Copy link to clipboard 
Print this post

  Gerad said  Isn't there a simpler way to transfer 10-20 bytes per day?


The programs in the link above provided a way for one 'mite to control another. If all you want to do is send data from time to time, just open a serial port and send it, terminated with carriage return and line feed.

There is no need to coordinate with the receiver. If the receiver has its serial port open, then it just needs to test in its main loop whether LOC(port#) is non zero. If it is, then data has arrived. A short pause will assure that the entire transmission is in the buffer. Then you can read it and process it.

If the transmission is all one way, it hardly matters how often the sender sends--it will all be buffered and can be extracted and processed at the convenience of the receiver.

LINE INPUT #fnbr, variable$ is a good way to get an entire transmission in a string (if it has been terminated with carriage return and line feed). You can then break out separate pieces of information with FIELD$.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Gerad
Newbie

Joined: 10/01/2024
Location: Germany
Posts: 37
Posted: 07:20pm 24 Apr 2024
Copy link to clipboard 
Print this post

Dear Gurus
Thank you very much for taking the time to help me.

Greetings
Gerad
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024