![]() |
|
|||||||
| Proton Plus Compiler v3 Coding problems and general discussion related to the Development Suite |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#31 |
|
Licensed User
![]() Join Date: Oct 2003
Location: CA
Posts: 1,233
![]() |
I am moving to 18F's, myself. The code specifies 18F only, though, and considering the compiler was designed for a variety of PIC series, I was wondering if it could be used with more of them with minor tweaking.
|
|
|
|
|
|
#32 |
|
Licensed User
![]() Join Date: Oct 2003
Location: CA
Posts: 1,233
![]() |
Oh, yeah... on top of that, there are numerous applications where you might not want your PIC as large as an 18 pin device.
|
|
|
|
|
|
#33 | |
|
Email Unconfirmed
Join Date: Oct 2007
Location: Scotland
Posts: 45
![]() |
Quote:
|
|
|
|
|
|
|
#34 |
|
Super Moderator
Join Date: Jan 2003
Location: london
Posts: 8,196
![]() |
Interrupts in basic are very very simple. No need for asm at all.
I write absolutely huge sections of code in interrupt routines but I then read the manual first and watch what system variables are used. ricky why have you not registered as a licenced user and tried out the new beta and used the new interrupt handling system? The macros system is BISVS but that is obsolete now that the new Beta is out.
__________________
Tim If in doubt read the manual |
|
|
|
|
|
#35 |
|
Licensed User
![]() Join Date: Apr 2006
Location: Erlangen, Germany
Posts: 85
![]() |
Hi,
I am using the invisible RS232 Serial buffering code in a data logger application together with SD/MMC card library. In addition, besides running unattend (remote locations), the application is meant to run with a PC host program via RS232/RS422. The host program polls the data logger hardware every second for data sets. I am using a 18F6722, 20 MHz. The data logger uses the EEPROM for some internal tracking issues, i.e. writes once a minute a byte and a dword to the EEPROM. When I started testing the setup for extended periods I've notized that after a couple of hours (12 - 24 h) the total EEPROM was overwriten (which in addition to the tracking variables holds some constants for calculating physical values from AD readings as well as a serial number and other house keeping data). I've switched to the beta compiler for better interupt handling (especially saving of system variables). No good. Since Friday the system runs flawless. What I did was to switch of interrupts (clearing GIE) at times when the PIC was writting the EEPROM. The 18F6722 manual states that its strongly recommended to switch of interrupts during EEPROM write operations. If I understand the assembler produced by the compiler right that is not happening (at least not in the EEPROM write routine). I assume that an interrupt event during the EEPROM write routine leaves the PIC after the return sometimes (not always) in an undefined state (?). Any other idea would be appreciated. My other concern is: Are there other routines which require absolut hardware access which I did not find up to now (for example writting the MMC card)? Greetings, Michael |
|
|
|
|
|
#36 |
|
Super Moderator
Join Date: Jan 2003
Location: london
Posts: 8,196
![]() |
Not fully correct in answer to your post but...
You do need to think about interrupts and eeprom writting and I as a matter of cause I turn off interrupts before doing so. However 5ms which is the average write time is a long time and you could miss chars coming in via USART. The solution is to time your eeprom writes in between the data packets. I.e. If your receiving set packets of data then set the eeprom write to occur when you see the whole packet has arrived. There are no other issues that I am aware of that are effected like the Eeprom in relation to being interrupted (hardware wise) One last thing writing to Eeprom every 5 mins will mean that you may have burned out the Eeprom in less than a year. Something to think about.
__________________
Tim If in doubt read the manual |
|
|
|
|
|
#37 |
|
Licensed User
![]() Join Date: Apr 2006
Location: Erlangen, Germany
Posts: 85
![]() |
Hi Tim,
thanks for the answer. To clarify things: first of all, the host program requests are coming asynchronous and not predictable. For example: "Send me data", "Send me your current RTC time" etc. In between, the host program user might request something. So, no way in predicting whats and when requests are coming. For writing the EEPROM: I am not writing the same cells every minute but instead use a range from $200 - $3FF. Where I change cells every minute. What I've meant with potential other issues: The SD/MMC card library uses either the hardwaer SPI port or a software SPI solution. Thats something which might be affected. The other one is the second RS232 in the 18F6722. I am using that to listen to the output of a GPS modul and determine time, date and position. Is that affected? Greetings, Michael |
|
|
|
|
|
#38 |
|
Super Moderator
Join Date: Jan 2003
Location: london
Posts: 8,196
![]() |
SPI port either serial or software is clock based so it can stand some clock stretching. The second rs232 your talking about is Usart based not software I take? Software based 232 timing would be damaged by the interrupt.
I would also consider not using the built in Proton context save interrupt routines as they impose an big overhead with all the system var saving it does. However if your running at a low baud rate then it might not be an issue, say 9600.
__________________
Tim If in doubt read the manual |
|
|
|
|
|
#39 |
|
Forum User
Join Date: Dec 2007
Posts: 8
![]() |
All you need to do is have a query/reply system which is flexible enough to account for missed characters in the fifo uart buffer.
Or even better, since the buffer is only 2 characters deep, have a two character query sent from the controlling computer, followed by waiting for the response. If the pic is busy (but watching the hardware uart flag) then the moment it can process the query it will do so. |
|
|
|
|
|
#40 |
|
Licensed User
![]() Join Date: Apr 2006
Location: Erlangen, Germany
Posts: 85
![]() |
Hi senacharim,
so, what you are saying is to switch off interrupt handling all together? The implementation right now is in a way that the host program sends the requests and the hidden buffer system the PIC handles the outside requests when its idle. Tim: I agree with what you are saying about SPI. I guess the same holds for I2C, cause its also clock driven. Greetings, Michael |
|
|
|
|
|
#41 | |
|
Forum User
Join Date: Dec 2007
Posts: 8
![]() |
Quote:
|
|
|
|
|
|
|
#42 | |
|
Licensed User
![]() Join Date: Aug 2004
Location: Central Scotland
Posts: 1,599
![]() |
Quote:
One extra pin to drive the CTS/RTS lines (with appropriate line drivers) to the PC. Put the pc comms on hold while writing to the eeprom. Last edited by bill9399; 22nd July 2008 at 15:41. |
|
|
|
|
|
|
#43 |
|
Licensed User
![]() Join Date: Apr 2006
Location: Erlangen, Germany
Posts: 85
![]() |
Hi,
unfortunately, there is no spare wire for a CTS/RTS handshaking. In any case, I abandoned the interrupt idea all together. Too much hasle and no big return value in terms of system responsiveness. Greetings, Michael |
|
|
|
|
|
#44 |
|
Licensed User
![]() |
Hi Les,
Since you publish this great program I use it in every RS232 communication project. Now I am planning to use it for RS485 communication (SN75176). The thing is the RS485 chip need to set the direction manually by the program. As you said it is invisible from the user, and I am no to macro. Where can I add the line for enabling the send/recieve of the chip. Kind Regards, |
|
|
|
|
|
#45 |
|
Super Moderator
Join Date: Jan 2003
Location: london
Posts: 8,196
![]() |
The decision to control the direction will be in the main code, probably around the TX commands so I would place them there.
__________________
Tim If in doubt read the manual |
|
|
|
|
|
#46 |
|
Licensed User
![]() |
Thanks for the reply Tim. Thats clear my confusion. In the beginning of my code I should enable the recieve pin then while sending do the reverse.
|
|
|
|
|
|
#47 |
|
Licensed User
![]() Join Date: Mar 2002
Location: Birmingham, Alabama USA
Posts: 943
![]() |
Another way you could deal with the problem would be to use an autodirection RS485 transceiver, like the Maxim MAX13410. Lots of their transceivers have this feature.
-Rick |
|
|
|
|
|
#48 |
|
Licensed User
![]() |
Hi Tim
Can I disable interrupt in the main code then enable it again as follows? From Les INIT_USART_INTERRUPT MACRO INTCON = %11000000 ' Enable global and peripheral interrupts Data Recieve From Main Code INTCON = %00000000 ' Disable global and peripheral interrupts Do something From Main Code INTCON = %11000000 ' Enable global and peripheral interrupts Again wait for data Hi rcurl Yes that was a good advice. I googled the net and I found a circuit for autodirection. It use a transistor and a few resistor. The second one use a 555IC configured as monostable. |
|
|
|
|
|
#49 |
|
Super Moderator
Join Date: Jan 2003
Location: london
Posts: 8,196
![]() |
Hi yes you can
However with the 485 coms set to output only then no interrupts should occur any case.
__________________
Tim If in doubt read the manual |
|
|
|
|
|
#50 | |
|
Licensed User
![]() |
Quote:
Another question. I setup another rs communication on another pin for the serial GLCD. Is that ok? ' USART DECLARE Declare HSERIAL_BAUD = 115200 ' Set baud rate to 9600,38400,115200 Declare HSERIAL_RCSTA = %10010000 ' Enable serial port and continuous receive Declare HSERIAL_TXSTA = %00100100 ' Enable transmit and asynchronous mode Declare HSERIAL_CLEAR = On ' Enable Error clearing on received characters ' GLCD Printing Declare RSOUT_PIN PORTB.4 Declare RSOUT_MODE 0 Declare SERIAL_BAUD 9600 Declare RSOUT_PACE 200 |
|
|
|
|
|
|
#51 |
|
Super Moderator
Join Date: Jan 2003
Location: london
Posts: 8,196
![]() |
Bear in mind that bit banged serial coms is timing critical and you need to prevent its being interrupted.
What speed is the USART com's? If its = or less than the bit banged then you can find a system that will work. That involves sending 1 char at a time to the GLCD. But I would need more info on what your going to send to be able to advise on details of the system.
__________________
Tim If in doubt read the manual |
|
|
|
|
|
#52 |
|
Licensed User
![]() |
USART PIN for 18f2620
TX portc.6 RX portc.7 Speed 115200 RSOUT PIN PORTB.4 Speed 9600 Yes TIM I am aware about the critical time of bit banged coms, it happened to me in one of my project. That is why I want to disable the interup while sending data to GLCD. As you said when the 485 is set to output no interrupt should occur, then that time I can send data to the GLCD. Or I can just tied the GLCD to tx (RC6) and set the address and set the baud of 485. Anyway I have to send only 1 character to GLCD. If 1 sent to GLCD = GLCD will print a logo 2 = GLCD will make animation 3 = GLCD will print "Hello WORLD" 4 ... 5 ... 6 ... All the printing will be done by the onboad PIC of the GLCD. I think that is the best way and I can free 1 precious pin. Last edited by dolci; 1st December 2008 at 11:24. |
|
|
|
|
|
#53 |
|
Licensed User
![]() |
I tried to use Les's wonderful serial buffer my code compile's with feedback from PDS the actual varaiables I used up minus the total actual ram! the PIC184550 contains about 2k but when I remove the routine I get a report of only 1k total ram
![]() Any I deas why this is happening? I appreaciate it!!! |
|
|
|
|
|
#54 |
|
Licensed User
![]() |
Opps!
Last edited by dolci; 16th January 2009 at 07:48. |
|
|
|
|
|
#55 |
|
Licensed User
![]() |
How much speed I can achieve at 20Mhz xtal? 30 meters distance.
Thanks, |
|
|
|
|
|
#56 |
|
Licensed User
![]() Join Date: Jun 2007
Location: figeac,FRANCE
Posts: 131
![]() |
hi everyone,
i'm using Les's serial buffer for debbuging and it works great! but like dolci i'd like to be able to use this code with the max485 drivers,i tried to thing about toggling port RB0 on the 18f1320 for example (a 10mhz 19200bds) i'll try to do some coding after i make the board and see what's happening when i just put something like: high portb.0 HRSOut Bytein low portb.0 etc... hope that works, i'm really not familiar with interrups i've done only one soft with it ... anyways thank you for your great code! fefenin |
|
|
|
|
|
#57 |
|
Licensed User
![]() |
This is what I've done and tried in Proton Board & Isis
Code:
Symbol RS485_Direction = PORTB.0 ; OUTPUT High RS485_Direction ; Enable Send CLEAR_SERIAL_BUFFER HSerOut [Str RS485Buffer,CR] Low RS485_Direction ; Enable recieve HSerIn 300,TIMEOUT,[Str RS485Buffer] TIMEOUT: |
|
|
|
|
|
#58 |
|
Licensed User
![]() Join Date: Jun 2007
Location: figeac,FRANCE
Posts: 131
![]() |
is it working dolci?
no time for testings now but i'll try later thank you fefenin |
|
|
|
|
|
#59 | |
|
Licensed User
![]() |
As I said
![]() Quote:
|
|
|
|
|
|
|
#60 |
|
Licensed User
![]() Join Date: Jun 2007
Location: figeac,FRANCE
Posts: 131
![]() |
thank you dolci!
i read that but what i meant was does it work properly in real... i guess you answered that too! i'll try that in "real" soon. and i'll tell you if i have some trouble to make it communicate fefenin |
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Font Converter | FabioPedro | The Lounge | 7 | 29th May 2007 19:22 |
| Pprint | FabioPedro | The Lounge | 18 | 21st April 2007 18:09 |
| Right2Left Alignment On a GLCD | SELCUK | Proton Plus Compiler v3 | 2 | 11th April 2007 07:40 |
| Is this correct ??? glcd | tbillion1 | Proton Plus v2.1.5.3 General Discussion | 4 | 19th September 2006 11:41 |
| Pprint | CALCO | Proton Plus v2.1.5.3 General Discussion | 2 | 13th July 2005 18:01 |