Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 07:26 17 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 : com port question

Author Message
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 09:56am 21 Feb 2015
Copy link to clipboard 
Print this post

Working on a project that will require the use of both com ports. I will only be using the TX line on both. This project is eating pins up and I find myself forced to use the 2 RX lines for reading a dip switch. My goal is to be able to start the program, set the 2 RX pins as DIN, read the two switches that are on the RX lines for config information (only in the beginning of the program) and then open the com ports and just transmit data. If the two RX lines are constantly tied high or low when I do the open com port but never try to receive any data (just transmitting), can this be bad in any way?

Thanks!!!!
 
Zonker

Guru

Joined: 18/08/2012
Location: United States
Posts: 761
Posted: 11:49am 21 Feb 2015
Copy link to clipboard 
Print this post

Humm..

Might cause some problems if the Rx pin is held low all the time... not sure... The firmware thinks a receive byte is starting... Try it and see what happens..
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5923
Posted: 11:52am 21 Feb 2015
Copy link to clipboard 
Print this post

If it is a problem, and you are able to use micromite Mk2's, you could use a CFunction to do the Tx. That allows any pin to be used and no Rx to worry about.

Jim
VK7JH
MMedit   MMBasic Help
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 12:33pm 21 Feb 2015
Copy link to clipboard 
Print this post

Hi TassyJim, that sounds like a better solution. I can define any i/o pin as a tx coms? Where can i find this information? I am using 170's for this project. 9600 baud also.
Thanks!!!
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 01:29pm 21 Feb 2015
Copy link to clipboard 
Print this post

A very interesting link.
Microblocks. Build with logic.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5923
Posted: 01:30pm 21 Feb 2015
Copy link to clipboard 
Print this post

The cfunction is included in the micromite Mk2 firmware ZIP that you download from Goeff's website.

http://geoffg.net/micromite.html

Jim
VK7JH
MMedit   MMBasic Help
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 01:37pm 21 Feb 2015
Copy link to clipboard 
Print this post

Holy Cow, this is an awesome cfuntion!!! Just what the doctor ordered! Completely solves my dilema.
Thanks again to the fine fine people of tbs!
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 10:44am 22 Feb 2015
Copy link to clipboard 
Print this post

Trying to use the Cfunction for Serial TX. MMbasic ver. 4.6b on 28 pinner. Here is the code I am trying to work with...



DIM CCMD(10)

CCMD(1)=&H7E:CCMD(2)=&HFF:CCMD(3)=&H06:CCMD(4)=&H00:CCMD(5)= &H00
CCMD(6)=&H00:CCMD(7)=&H00:CCMD(8)=&H00:CCMD(9)=&H00:CCMD(10) =&HEF

PIN(3) = 1
SETPIN 3, DOUT

FOR X = 1 TO 10
P = SERIALTX( 1, 9600, CHR$(CCMD(X)))
NEXT X


CFunction SerialTx 00000070
00001021 40824800 40024800 0044102b 1440fffd 00000000 03e00008 00000000
3c03bf81 8c65f000 3c02003d 24420900 7ca51400 70a23002 8c63f000 3c040393
34848700 7c6316c0 00c41021 00621007 3c03029f 24636300 50430003 3c0202dc
03e00008 00000000 03e00008 24426c00 27bdffc0 afb70034 afb1001c afb00018
00c0b821 afa50010 afbf003c afbe0038 afb60030 afb5002c afb40028 afb30024
afb20020 00808021 0411FFDD 00000000 8fa50010 82e30000 8cb10000 00118840
0051001b 022001f4 1860002e 00008812 24160001 3c14bf88 3c15bf88 24120001
8e020000 02202021 00521004 ae826034 24020008 afa20010 241e0001 0411FFC0
00000000 02f69821 1000000c 8fa20010 00721804 aea36038 02202021 afa20010
0411FFB7 00000000 8fa20010 001ef040 2442ffff 10400009 33de00ff 82630000
03c31824 1460fff2 8e030000 00721804 ae836034 1000fff1 02202021 8e020000
02202021 00521004 aea26038 0411FFA4 00000000 82e20000 02c2102a 1440ffd8
26d60001 8fbf003c 00001021 00001821 8fbe0038 8fb70034 8fb60030 8fb5002c
8fb40028 8fb30024 8fb20020 8fb1001c 8fb00018 03e00008 27bd0040
End CFunction


When I run this I get...

CPU exception #10
In CFunction at address 0x9D000A38
Processor restarted

This code works fine if I use the regular open com port and print#1 etc...

Any ideas as to what I am doing wrong?

Thanks!!!!

EDIT... the weird spaces in the array are not in my code.Edited by viscomjim 2015-02-23
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3167
Posted: 03:59pm 22 Feb 2015
Copy link to clipboard 
Print this post

I fully tested this CFunction so it should work - but your experience does not sound good. Give me a day or two to investigate.
Geoff Graham - http://geoffg.net
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 05:18pm 22 Feb 2015
Copy link to clipboard 
Print this post

Thanks Geoff. This is a great addition and suits my particular project really well. I hope this is just a fluke and I did something weird.
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3167
Posted: 08:16pm 22 Feb 2015
Copy link to clipboard 
Print this post

Ah, found it. It was a documentation error. Line 14 should read:

CFunction SerialTx 0000001C

I will update the documentation and the download on my website.

Geoff
Geoff Graham - http://geoffg.net
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2294
Posted: 01:03am 23 Feb 2015
Copy link to clipboard 
Print this post

hi geoff,
a quick question about the SerialTx function, which has been in the back of my mind since the code for it was released:

the documentation states, "Will work with up to four I/O pins on the 28-pin Micromite", and goes on to give the restriction that the pins be 2, 3, 9, and 10.

why are the pins restricted to just these four? and since pin 9 is already "COM2: TRANSMIT", surely the function only usefully supports 3 pins? also, why the need for the setpin() command before first using the function? can SerialTx() not configure the pin itself?

i'm assuming that SerialTx is a software uart, since the top baudrate is quite low.

if using software to generate the data stream, there seems no obvious reason why any I/O pin could not be used, and that in this case the syntax would be simpler to understand by referencing the pin number directly (rather than a port number indexing into a lookup table). the simplified syntax would then be:

r = SerialTx( <pin>, <baudrate> , <message> )

with the pin configured as an output automatically upon the first call.


cheers,
rob :-)
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 04:58am 23 Feb 2015
Copy link to clipboard 
Print this post

The change to that line (1C) worked perfect.

Thanks!!!!
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3167
Posted: 02:52pm 23 Feb 2015
Copy link to clipboard 
Print this post

  robert.rozee said  the documentation states, "Will work with up to four I/O pins on the 28-pin Micromite", and goes on to give the restriction that the pins be 2, 3, 9, and 10.

why are the pins restricted to just these four? and since pin 9 is already "COM2: TRANSMIT", surely the function only usefully supports 3 pins? also, why the need for the setpin() command before first using the function? can SerialTx() not configure the pin itself?

i'm assuming that SerialTx is a software uart, since the top baudrate is quite low.

if using software to generate the data stream, there seems no obvious reason why any I/O pin could not be used, and that in this case the syntax would be simpler to understand by referencing the pin number directly (rather than a port number indexing into a lookup table). the simplified syntax would then be:

r = SerialTx( <pin>, <baudrate> , <message> )

with the pin configured as an output automatically upon the first call.

It really comes down to the fact that a CFunction cannot call MMBasic routines and it knows nothing about what is going on within MMBasic.

In MMBasic there are functions that map pin numbers to PIC32 registers for manipulating I/O pins but they are too complicated for a CFunction. So a crude mechanism is used by the CFunction to address the I/O pins and that causes the restrictions that you mentioned.

I am working on a mechanism that will allow limited calls into MMBasic and when that is in place (in a future version) you will be able to use pin numbers in a CFunction and then use MMBasic to manipulate the PIC32 registers. At that time I will be able to produce a CFunction with your suggested syntax.

GeoffEdited by Geoffg 2015-02-25
Geoff Graham - http://geoffg.net
 
MolsonB
Regular Member

Joined: 25/01/2015
Location: Canada
Posts: 48
Posted: 07:16am 10 Jun 2015
Copy link to clipboard 
Print this post

I checked the 'Micromite MMBasic Library(s)' and it still has the old code as the first line.
CFunction SerialTx 00000070


Changing it to
CFunction SerialTx 0000001C
worked.


MkII 44pin - v5.0

ColorMax 2 - v4.5
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 08:12am 10 Jun 2015
Copy link to clipboard 
Print this post

Hi MolsonB, glad you saw that fix. I believe I read somewhere that you can now use this function on any I/O pin. Not sure where I read this but I think it was part of the latest beta.
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3167
Posted: 12:01pm 10 Jun 2015
Copy link to clipboard 
Print this post

  MolsonB said   I checked the 'Micromite MMBasic Library(s)' and it still has the old code as the first line.
CFunction SerialTx 00000070

What entry in the library was at fault?
Geoff Graham - http://geoffg.net
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 12:02pm 10 Jun 2015
Copy link to clipboard 
Print this post

Back when I ran into this it was the serial TX cfunction.

HERE is linkEdited by viscomjim 2015-06-11
 
MolsonB
Regular Member

Joined: 25/01/2015
Location: Canada
Posts: 48
Posted: 01:07pm 10 Jun 2015
Copy link to clipboard 
Print this post

Correct, the very first line in CFunction SerialTx 00000070. Should be 0000001C as you guys found out in this thread. Just the library docs haven't been updated yet.
MkII 44pin - v5.0

ColorMax 2 - v4.5
 
Print this page


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

© JAQ Software 2024