If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Hi Joe, thank you for your reply.
My perplexity still remain, I don't think anything in MODEDEFS.BAS can interfere with HSERIN command.
The XOUT command was working without MODEDEFS.BAS file (because I am using my own X10 coding), the only problem was that I had to use SERIN2 instead of HSERIN .
Al.
All progress began with an idea
Hi Al,
It was HSERIN that didn't work . . . Thought it was the x10 code . . . I should have read it through . . . might have something to do with the RX ports idle state, perhaps the code in modedefs.bas affected it that way. I DO know hserin likes to idle high.
Last edited by Archangel; - 9th May 2009 at 20:00.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Are you using the TX pin for XOUT? If so, yes It may give you some weird problem, because XOUT may try to modify the TRIS setting, and/could disable the USART.
Try
RCSTA=0 before XOUT
RCSTA=$90 after Xout
and see how good, worst it is.
From what I know, there's no good reason why MODEDEFS should solve the problem. If it wasn't there, you would probably have some compilation error but not much.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Thank you Joe and Steve,
Pins RB1(Rx) and RB2(Tx) are used to service the serial connection with the Xbee module. Xout uses pin RB6; Xin uses pin RB4 and zerocrossing is on pin RB6. Here the code:
Code:INCLUDE "Modedefs.bas" INCLUDE "DT_INTS-14_2.bas" ; Base Interrupt System INCLUDE "ReEnterPBP.bas" ; Include if using PBP interrupts CMCON = 7 TrisA = %00000000 TrisB = %00110010 PortA = 0 DEFINE OSC 10 DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1 DEFINE HSER_SPBRG 64 ' 9600 Baud @ 10MHz, 0,16% DEFINE HSER_CLROERR 1 ' Clear overflow automatically XbDtr var PortB.0 XbRts var PortB.3 XbSlp var PortA.3 Pwr var PortA.0 Led var PortA.1 Buz var PortA.2 X10Rx var PortB.4 ZCrox var PortB.5 X10Tx var PortB.6 TxEnable var PortB.7 high Pwr high XbSlp low TxEnable low XbRts Low XbDtr A0 var Byte House var byte Unit var Byte Job var Byte Decode var byte Pass var byte Rdata var Byte[10] HouseKey var word '--------------------------- Rx DT interrupt definition ------------------- ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler RX_INT, _Getbytes, PBP, no endm INT_CREATE ; Creates the interrupt processor ENDASM @ INT_ENABLE RX_INT ; enable RX_INT interrupts '------------------------------------------------------------------------- gosub Buzzer Main: pause 1 If Rdata[0]=250 then loop goto main Getbytes: Hserin 100,ErrorFlag,[str Rdata\9] High led If Rdata[0]=36 then House = ((Rdata[4]-48)*10) + (Rdata[5]-49) Unit = ((Rdata[6]-48)*10) + (Rdata[7]-49) Decode = Rdata[8]-48 If decode = 1 then Job = 18 : Pass = 1 If decode = 2 then Job = 26 : Pass = 1 If decode = 50 then Job = 20: Pass = 1 If decode = 51 then Job = 28: Pass = 1 gosub TxCommand endif Pass=0 Low led @ INT_RETURN ErrorFlag: RCSTA.4 = 0 RCSTA.4 = 1 Pass=0 low led @ INT_RETURN TxCommand: If Pass=0 then return High TxEnable pause 1 Xout X10Tx,Zcrox,[House\Unit,House\Job] low TxEnable Buzzer: high buz pause 20 low buz return Loop: xin X10Rx,ZCrox,[Housekey] hSerout ["H: ",#Housekey.byte1,13,10] hserout ["K: ",#Housekey.byte0,13,10] goto loop
Now the code works with the exception of HSEROUT that I was anable to get it to work in the "Main" loop. I had to make the trick to jump in a secondary loop "LOOP" to have it working, but if I re-enter the "LOOP" the second time then HSEROUT doesn't work anymore. There must be something effecting the USART setting using Xin and Xout command.
I should mention once again that pic16F628 is working @ 3.3 Volts. No compilation errors without Modedefs.bas file.
Any tip will be welcome!
Al.
Last edited by aratti; - 9th May 2009 at 23:51.
All progress began with an idea
Hi Aratti,
This could be a problem.
In the Main loop, actually Loop:, there is an XIN statement that runs on every loop. Then if you receive data in the interrupt handler, the TxCommand is called which does an XOUT. The XOUT could potentially be triggered in the middle of the XIN. Possibly leaving XIN waiting for something it will never receive.
That could keep the HSEROUT's from being executed.
If you set a "flag" in the interrupt handler when it receives data, then do the XOUT in the main loop when it sees the flag, it won't try to do both XIN and XOUT at the same time.
Added: You may also need to have the RX interrupt receive bytes 1 at a time instead of a full string, to keep it from interfereing with the XIN to begin with.
hth,
Last edited by Darrel Taylor; - 10th May 2009 at 02:23. Reason: Added:
DT
Hi Darell, thank you for your answer. I did try your suggestion without any luck.
In doing these changes I came to the conclusion that Xin command is the problem, infact simply removing Xin from the code and Txing numbers with a For/Next loop everything work fine. As soon as I enable Xin the problem is back again.
At this time it seems I have got only one bullet left "use two pics" one for Xin and one for Xout.
Al.
Last edited by aratti; - 10th May 2009 at 18:13.
All progress began with an idea
Bookmarks