Home  |  Contents 

Microcontroller and PC projects
  Forum Index : Microcontroller and PC projects         Section
Subject Topic: Pi-cromite 5.04.17: Sprites Post ReplyPost New Topic
<< Prev Page of 5
Author
Message << Prev Topic | Next Topic >>
lew247
Guru
Guru
Avatar

Joined: 23 December 2015
Location: United Kingdom
Online Status: Offline
Posts: 925
Posted: 26 June 2018 at 8:35pm | IP Logged Quote lew247

Not sure if this is a bug or if it needs to be called something else

but when I try and call a function it says

Function Atan2(x,y)
Error: Invalid identifier

the code works on the normal MM


Back to Top View lew247's Profile Search for other posts by lew247
 
matherp
Guru
Guru


Joined: 11 December 2012
Location: United Kingdom
Online Status: Offline
Posts: 2164
Posted: 26 June 2018 at 10:10pm | IP Logged Quote matherp

Atan2 is a built-in function in the MMX and Pi-cromite. Just delete your Basic version
Back to Top View matherp's Profile Search for other posts by matherp
 
lew247
Guru
Guru
Avatar

Joined: 23 December 2015
Location: United Kingdom
Online Status: Offline
Posts: 925
Posted: 26 June 2018 at 10:47pm | IP Logged Quote lew247

oh nice, thanks Peter
Back to Top View lew247's Profile Search for other posts by lew247
 
lizby
Senior Member
Senior Member


Joined: 17 May 2016
Location: United States
Online Status: Offline
Posts: 177
Posted: 12 July 2018 at 11:56am | IP Logged Quote lizby

I'm trying to write to a 24LC64 eeprom with Pi-cromite mmbasic on a pi zero w.

I don't clearly see how to specify the address to be written, but in this thread, grogster, et. al., put in the address bytes before the bytes to be written:

Dim A=1 'Address byte
...
I2C WRITE &B1010000,0,6,A\256,A Mod 256,B,C,D,E 'Write four bytes from address 1

I'm trying to write a 4K+ character file with this code.

' write 24LC64 eeprom
' option i2c 3,5 ' not valid within a program
open "watermon_chart.html.template" for input as 1
dim as string A
dim as integer i = 0, iflag = 0
CONST cFE=chr$(254)
CONST cFF=chr$(255)
i2c open 100,100

do
  A = input$(16,1)
  ? A
  if len(A) <> 16 then
    A = A + cFE + cFE + cFE + cFE + cFE + cFE + cFE + cFE + cFE + cFE + cFE + cFE + cFE + cFE + cFE + cFE
    A = mid$(A,1,16) '  truncate to 16 characters
    iflag = 1
  endif
  i2c write &H50,0,18,i\256,i Mod 256,A ' write 2 address bytes and 16 data bytes
  Pause 10 'make sure EEPROM has time to write(5ms needed) 
  i = i + len(A)
  if iflag = 1 then
    exit
  endif
loop
close 1
? i

I'm reading (and writing) 16 bytes at a time, and if the last read is less than 16 bytes, filling in with 0xFE.

The error message on the first write says "Error: Argument count".



(I had to enter "OPTION I2C 3,5" at an MMBASIC ">" prompt to get past an objection that the I2C pins weren't defined--are all pins available with picromite i2c?)

How do I specify an address to be written for the eeprom?

Back to Top View lizby's Profile Search for other posts by lizby
 
matherp
Guru
Guru


Joined: 11 December 2012
Location: United Kingdom
Online Status: Offline
Posts: 2164
Posted: 12 July 2018 at 5:10pm | IP Logged Quote matherp

Quote:
The error message on the first write says "Error: Argument count".


Your syntax is incorrect - check the Micromite manual Appendix B. You can either have a list of single variables or an array/string not both.

Quote:
(I had to enter "OPTION I2C 3,5" at an MMBASIC ">" prompt to get past an objection that the I2C pins weren't defined--are all pins available with picromite i2c?)


Yes, the I/F is bitbanged as the Pi has known issues with clock stretching and the bitbang code does this properly
Back to Top View matherp's Profile Search for other posts by matherp
 
lizby
Senior Member
Senior Member


Joined: 17 May 2016
Location: United States
Online Status: Offline
Posts: 177
Posted: 12 July 2018 at 10:11pm | IP Logged Quote lizby

Thank you. This worked:

A = chr$(i\256)+chr$(i Mod 256)+A
i2c write &H50,0,18,A ' write 2 address bytes and 16 data bytes

4144 bytes written.

At long last: a convenient way to write bulk data to an 8-pin eeprom.


Edited by lizby on 12 July 2018 at 10:17pm
Back to Top View lizby's Profile Search for other posts by lizby
 


If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Search the forums using Google.
<< Prev Page of 5
In the news...
 
Post ReplyPost New Topic
Printable version Printable version
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

Powered by Web Wiz Forums version 7.8
Copyright ©2001-2004 Web Wiz Guide

This page was generated in 0.1250 seconds.
Privacy Policy     Process times : 0, 0.01, 0, 0.12