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 : Machine code for SetPin 2,din
Page 1 of 3 | |||||
Author | Message | ||||
rogersan Regular Member Joined: 10/04/2015 Location: AustraliaPosts: 79 |
To get the DHT11 software to work for the DHT22 I want to move the SetPin 2,din into the start of CFunction dht11conv Could someone give me the machine code for SetPin 2,din so I can add it into the CFunction. . |
||||
twofingers Guru Joined: 02/06/2014 Location: GermanyPosts: 1139 |
AFAIK can you get the whole Micromite code from Geoff. Regards Michael |
||||
rogersan Regular Member Joined: 10/04/2015 Location: AustraliaPosts: 79 |
Hi Michael Sorry I do not understand your reply, what is AFAIKT? Would Geoff give me the listing of his Basic Interpreter so I can find the machine code for SetPin 2,din. To get the machine code to SetPin 2,din, I need to set bit 0 of portaA data direction register, Do I have to download an assembler or C just to get this code? It used to be possible to get this from the manual of a microprocessor where each instruction was described and the machine code given. |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8601 |
rogersan It isn't as easy as that, SETPIN does more than just set the appropriate bit in the data direction register. I wrote the DHT11 Cfunction in response to a request to support that specific sensor. The DHT22 is already fully supported by the Micromite MKII firmware so there was no need to cover that as well. I don't have a DHT22 to test with so can't amend/test the Cfunction for the DHT22 If you want to do it yourself the C code is attached to my original listing and full details of how to write/compile Cfunctions is given on G8JCF's website |
||||
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2794 |
As Far As I Know (no 'T') For everything Micromite visit micromite.org Direct Email: whitewizzard@micromite.o |
||||
twofingers Guru Joined: 02/06/2014 Location: GermanyPosts: 1139 |
Thanks WW! @Roger AFAIK you will find the Micromite source (for personal use) here. Also valuable for any Micromite user: http://geoffg.net/micromite.html Regards Michael |
||||
rogersan Regular Member Joined: 10/04/2015 Location: AustraliaPosts: 79 |
The DHT22 function in Micromite V 4.6 does not work at low temperatures, I will have to send my Micromite back to a Silicon Chip to reprogram it to V 4.6B, or buy a programmer. I also found the the DHT11 read program would only work once, you cannot place it in a loop as you get an error message the second time it Is called. Using SetPin(2)=1 if pin 2 is an defined already an input will give an error message. You can SetPin(2)=1 before you make pin 2 into an input or an output, but not if it defined as an input. This is strange you are just writing to the portaA output register, so it should not matter whether it is an output or input. To allow the DHT11 read routine to be called more than once, I do this. Initialise SetPin(2)=0 'pin 2 will be forced low when it is set to be an output Pin 2,din In the DHT11 routine to pulse pin 2 low Pin 2,dout 'force pin 2 low Pause 1. ' for 1 millisec Pin 2,din. 'Pin 2 high again Unfortunately the time it takes for Pin 2,din and the call to th CFunction to read the DHT11 takes so long that the CFunction misses the first low going pulse from the DHT22. So I would like to put the Pin 2,din at the start of the CFunction. This means the low pulse from the Micromite is terminated in the CFunction so that it should not miss the reply from the DHT22. So what do I need to add to the start of the CFunction to do this? |
||||
WhiteWizzard Guru Joined: 05/04/2013 Location: United KingdomPosts: 2794 |
@rogersan Just to clarify something: You quote: 'Pin 2,dout' & 'Pin 2,din' but my understanding when using 'din' and 'dout' is that it is used with 'SetPin(x), ...'. To configure a pin as a digital input you use SETPIN(x),DIN (or SETPIN x,DIN) To configure a pin as a digital output you use SETPIN(x),DOUT (or SETPIN x,DOUT) Then to switch a digital output as high or low you use: PIN(x)=1 (to set high) PIN(x=0 (to set low) Not sure if this will help you resolve things . . . . WW For everything Micromite visit micromite.org Direct Email: whitewizzard@micromite.o |
||||
rogersan Regular Member Joined: 10/04/2015 Location: AustraliaPosts: 79 |
You are right, I wrote the message without the code in front of me. My options at the moment to reliably read a DHT22 is to have my Micromite II reprogrammed as V4.6B. Or Learn how to write a CFunction |
||||
BobD Guru Joined: 07/12/2011 Location: AustraliaPosts: 935 |
You should consider getting a programmer. They are cheap. Updates to the firmware will occur occasionally. It could cost you more to get others to do the work for you. That said, if you indicate approximately where you are then you may find someone able to help you. |
||||
rogersan Regular Member Joined: 10/04/2015 Location: AustraliaPosts: 79 |
To learn how to write CFunctions for the Micromite II, is the 74 page MMbasic Mark II CFunctions Manual the one to use? |
||||
rogersan Regular Member Joined: 10/04/2015 Location: AustraliaPosts: 79 |
To set the data direction of portaA bit 0 TO AN INPUT can be done by writing Ox0001 to the register TRISASET, however I need the address of the TRISASET register for the C program. Can anyone give me the address of the TRISASET register for the PIC32MX170F256-50i/SP? |
||||
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9075 |
Would not the Microchip datasheet for the PIC32 chip not give you that information? I have never needed to delve into Cfunctions - yet - so I don't know if that info is in the manual or not. Smoke makes things work. When the smoke gets out, it stops! |
||||
rogersan Regular Member Joined: 10/04/2015 Location: AustraliaPosts: 79 |
Reading the fine print on the Datasheet there is an offset of 8 between the address of TRISA and TRISASET so the address of TRISA is BF886010 in hexadecimal and the address of TRISASET is BF886018 So for the CFunction I will try #define portad *(volatile unsigned int *)Oxbf886018 //portasetdir Portad=1; //pin 2 now an input |
||||
G8JCF Guru Joined: 15/05/2014 Location: United KingdomPosts: 676 |
I think that perhaps plib.h may be what you need Peter The only Konstant is Change |
||||
rogersan Regular Member Joined: 10/04/2015 Location: AustraliaPosts: 79 |
The C Make File plib.h is very impressive for the range of functions it makes available. It is certainly worth using for complex projects written in C. |
||||
rogersan Regular Member Joined: 10/04/2015 Location: AustraliaPosts: 79 |
Trying to download the X32 compiler from Microchip. The MAC address of my PC is required, I got this but the download page keep saying it is invalid, The MAC STARTS with E0 but this is not accepted. Any suggestions? |
||||
G8JCF Guru Joined: 15/05/2014 Location: United KingdomPosts: 676 |
Hi @rogersan I've never heard of anyone having a problem like the one you've described, when I downloaded XC32 for Windows after I had installed MPLAB/X I can't recall MCHP asking for my MAC address. Has anybody else experienced what @rogersan is going through ? Peter The only Konstant is Change |
||||
rogersan Regular Member Joined: 10/04/2015 Location: AustraliaPosts: 79 |
I found that the MAC address would only be accepted if you take out the dashes. You can then run a .bat file. This still does not download XC32 which you have to do separately. I tried MPLAB V3.3 to create a CFunction but this does not have an "Additional Options" box in Project Options, so you cannot enter -fPIC -mono -abicals which is critically important. |
||||
G8JCF Guru Joined: 15/05/2014 Location: United KingdomPosts: 676 |
Hi, this might help people make sure their MPLab/X + XC32 installation and configuration is correct 2015-05-03_144234_MPLabCheckout.zip Peter PS, @RogerSan I've sent you an email directly about this. The only Konstant is Change |
||||
Page 1 of 3 |
Print this page |