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 : Micromite SPI
Author | Message | ||||
palcal Guru Joined: 12/10/2011 Location: AustraliaPosts: 1873 |
I was using a DTX2-2800C GPS from Dimitech with the MM and it worked OK. I have tried to convert the code to work with the Micromite but am having a problem, the GPS keeps returning a value of 255. SPI is fairly new to me so any help would be appreciated. The code I am using is Dim arg$(20)
SetPin 10,8:Pin(10) = 1 SPI OPEN 5000000, 3, 8 Pin(10) = 0 b=SPI(&h3b) GPS: GoSub GPS2 If arg$(0) = "GPRMC" Then 'GPRMC contains lat, lon If arg$(2) = "A" Then 'A means locked to satellite Lat = Val(Mid$(arg$(3), 3)) 'latitude in decimal Lon = Val(Mid$(arg$(5), 4)) 'longitude in decimal EndIf EndIf Print lat,lon Pause 500 GoTo GPS GPS2: Do Do While Chr$(SPI(0))<> "$":Loop 'wait for the start For i = 0 To 20 arg$(i) = "" 'clear ready for data Do 'loops until specific exit x$=Chr$(SPI(0)) 'get the character If x$="," Then Exit 'new data field, increment i If x$="*" Then Return 'we have all data so return arg$(i) = arg$(i) + x$ 'add to the data Loop 'loop back for next char. Next i 'move to the next data field Loop Paul. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
kiiid Guru Joined: 11/05/2013 Location: United KingdomPosts: 671 |
The clock is too high. Should be up to 4MHz http://rittle.org -------------- |
||||
palcal Guru Joined: 12/10/2011 Location: AustraliaPosts: 1873 |
Still no go. I connected to the Maximite just to confirm and all is OK. So I reconnected to the Micromite using the 150 chip and checked all connections back to the actual chip. I changed the clock speed to 3Mz. and changed SPI(&H80) to SPI(&h3b) and used the code exactly as in the example on page 47, except I use Pin(7) instead of Pin(11). and all it returns is values of 255. Paul. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
kiiid Guru Joined: 11/05/2013 Location: United KingdomPosts: 671 |
Are those pins supported by the SPI command? I have never tried the new micromite firmware neither have any details about its organisation so can't say anything about it from that point of view. http://rittle.org -------------- |
||||
paceman Guru Joined: 07/10/2011 Location: AustraliaPosts: 1329 |
Paul, The MicroMite has fixed SPI pins whereas with the Maximite they could be assigned to any pins. from MicroMite manual: I/O Pins
For 28 pin chips pin 25 will become the clock output, pin 14 will be the data in (MISO) and pin 3 will become the data out (MOSI). For 44 pin chips pin 14 is the clock, pin 41 the data in and pin 20 the data out. When the SPI CLOSE command is used these pins will be returned to a “not configured” state. Then can then be configured as per normal using SETPIN. An SPI enable signal is often used to select a slave and “prime” it for data transfer. This signal is not generated by this function and (if required) should be generated using the PIN function on another pin. Greg |
||||
palcal Guru Joined: 12/10/2011 Location: AustraliaPosts: 1873 |
I am using all the correct pins, the GPS module tests OK, and the code is very simple. But it just wont work. Paul. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
graynomad Senior Member Joined: 21/07/2010 Location: AustraliaPosts: 122 |
Lat = Val(Mid$(arg$(3), 3)) 'latitude in decimal
Lon = Val(Mid$(arg$(5), 4)) 'longitude in decimal ... Print lat,lon Are variable names not case sensitive in MM BASIC? Rob Gray, AKA the Graynomad, www.robgray.com |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6101 |
"Naming Conventions Command names, function names, labels, variable names, file names, etc are not case sensitive, so that "Run" and "RUN" are equivalent and "dOO" and "Doo" refer to the same variable." Jim VK7JH MMedit  MMBasic Help |
||||
graynomad Senior Member Joined: 21/07/2010 Location: AustraliaPosts: 122 |
OK, thanks. Rob Gray, AKA the Graynomad, www.robgray.com |
||||
Print this page |