Not until seeing your question. That seems to do it. It compiles and only uses 593 words so I think it will be OK, now.Originally Posted by Darrel Taylor
Will the pin change functions work with the 12F683?
Not until seeing your question. That seems to do it. It compiles and only uses 593 words so I think it will be OK, now.Originally Posted by Darrel Taylor
Will the pin change functions work with the 12F683?
Last edited by dhouston; - 1st August 2006 at 17:16.
Awesom,
Sure will.Will the pin change functions work with the 12F683?
Add these two lines in the ASM section right before the INT_LIST
RBIF = GPIF
RBIE = GPIE
(no space at the beginning of the line)
Then use RBC_INT.
<br>
DT
Thanks. Spending $0.25-0.30 more for the 12F683 vs. the 12F629 is worth it to be able to use Instant Interrupts.Originally Posted by Darrel Taylor
I like the 683 too. If for nothing more than the CCP module. Of course the extra RAM and program space is also handy.
With the 629 only having 64 bytes of RAM,
PBP uses 24-26 bytes
and DT_INTS-14 and ReEnterPBP want 31 bytes of it (without T? vars)
Which only leaves about 6-7 bytes for the program. Not much you can do with that.
But, when using ASM interrupt handlers, DT_INTS-14 only needs 7 bytes of RAM, leaving around 38 bytes for the users program. Now that, is workable. It also uses less program space that way.
You mentioned earlier that you only needed to toggle a pin in the interrupt, so you might take a look at this page...
DT_INTS-14 (Assembly Language Interrupts)
http://www.darreltaylor.com/DT_INTS-14/asm_ints.html
The ToggleLED1: handler does just that. And if the other handlers aren't too tuff, you might still fit it in a 629.
HTH,
DT
Darrel
I'm going to be moving a project from a 16F88 to an 18F1320. The reason for the move is the 18F1320 has 3 external interrupts, 2 of which I will be using. Currently I'm using instant interrupts and INT_INT on the 16F88. The question is will instant interrupts work with multiple external interrupts? I see in the datasheet that the external interrupts have numbered flags.
See http://darreltaylor.com/DT_INTS-18/home.html. Darrel has done a good job documenting the Instant Interrupts, and it shows on the right side of the page that multiple external interrupts are implemented.Originally Posted by DynamoBen
Steve
Thanks Steve, I forgot that he was using a separate version for the 18Fs.
Its now 7:34 am, I just read this thread from start to finish, I would like to say it went completely over my head but some must have aimed a bit lower as I now have one hell of an headache........
I read it as I have just got a shiny new programmer and a 18f2550, I was looking for ways to port some old f88 stuff I wrote that used serial comunication, I want to it to use usb...
I found that they are some examples to make the 2550 emulate a serial port, and I may go that way, seems easier to port that way.
Then I read more and got more ambitious, and was wondering if I can port it over with the 2550 running fake serial over usb, but drop a bootloader in it before my old f88 code and use the bootloader over usb, then I wont need to use my pc serial port at all?
To summise, can I re-burn the chip via usb with a boot loader to debug my ported f88 code?
If I can, am I right in thinking all I need is to give up one i/o line to a switch to trigger the bootloader?
And like most things come in three's (especially questions), how to edit/burn to usb? with the f88 I usually create a hex file, quit basic, load the programmer software (winpic/whatever) and burn chip, remove from programmer, get a pin stuck in thumb and lose blood, stick in proto board, bend a pin etc...
Lez, you might want to check the USB forum for that information.
Robert
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
Originally Posted by DynamoBen
Maybe assigning high & low priorities might help you:
http://darreltaylor.com/DT_INTS-18/LowPriority.html
One problem I am having now is that an internal interrupt (USB Service) seems to lose connection after I use an external interrupt (incoming USART data). Assigning a priority to each is just what I'm about to test and see how things go.
Robert
Last edited by Demon; - 15th August 2006 at 05:22.
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
Sounds like a good idea.
Since an HSERIN can take up to several hundred milliseconds (depending on baud rate and data size), it's best to have HSERIN in a Low Priority handler.
And things that "must" go without fail, in the High Priorities.
DT
Yup, that's what I was thinking, having the USB SERVICE come first, and have the USART interrupt 'whenever'.
Edit: WEEE !!!
Robert
Last edited by Demon; - 15th August 2006 at 05:22.
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
Darrel,
How about this one? I have one interrupt to generate a USB Service, that part works fine. I'd like to add another interrupt for USB reception, is that what USB_INT is for?
Here is a snip of code:
Does that make sense? Or can I leave the USB Service interrupt enabled throughout the USB Reception interrupt?Code:;----[High Priority Interrupts]----------------------------------------------- ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler TMR1_INT, _ServiceUSB, PBP, yes INT_Handler USB_INT, _ReceiveUSB, PBP, yes endm INT_CREATE ; Creates the High priority interrupt processor ENDASM '---[USB - interrupt handler]------------------------------------------------ ReceiveUSB: @ INT_DISABLE TMR1_INT ; disable USB service interrupt USBBufferCount = USBBufferSizeRX DoUSBIn: USBservice ; Generate USB Service manually USBIn 1, USBBuffer, USBBufferCount, DoUSBIn varUsbIn = conByteHigh ' Set flag data has arrived @ INT_ENABLE TMR1_INT ; enable USB Service interrupts @ INT_RETURN '---[TMR1 - interrupt handler]-------------------------------------------------- ServiceUSB: USBservice @ INT_RETURN
Robert
Last edited by Darrel Taylor; - 15th August 2006 at 08:45. Reason: added [code][/code] tags
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
almost 3 Am here.. it sounds good to me BUT i'll suggest to remove the USBSERVICE in the INT handler... m i'm sure i miss something anyway...
Last edited by mister_e; - 15th August 2006 at 09:04.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Well, I don't really know.
But, the datasheet for the 18F4550 shows 12 different interrupts from the USB module that all funnel into the single USB_INT. So I doubt it's that easy.
But if I were going to try it, I might set the ...
TRNIE: Transaction Complete Interrupt Enable bit
and see what happens.
DT
Added: and then all the others just to be sure.
See there, you're always ahead of me. Was only midnight here.Originally Posted by mister_e
DT
Either I'm really dumb today (I blame last night) or their is no usb sub forum etc on here!Originally Posted by Demon
found a few threads, gave me some stuff to read and I'm about ready to try and knock up a pcb to test the chip with, then i'll have a go with the mouse circle hid to test wiring, then throw in the serial demo and expand on that, thanks.
Last edited by Demon; - 4th October 2016 at 19:42.
Here's the USB forum
http://www.picbasic.co.uk/forum/forumdisplay.php?f=18
Must have been a Good Night
<br>
DT
Originally Posted by Darrel Taylor
WHAT DO YOU MEAN "You don't know?"
Hmmm, I would tend to believe that flag does not distinguish between upload and download transactions; I really need a PC-to-PIC complete flag.
Well, since I have an interrupt controlling user input on the PIC, I can just loop the PC-to-PIC USB routine. This will make things much easier to manage, I'm not very fond of using that all-encompassing USB_INT interrupt.
Now if I can only find out why Windows won't recognize the device, things would be peachy:
http://www.picbasic.co.uk/forum/show...8&postcount=55
Robert
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
Hi Darrel,
I've found out why my device is not recognized, the USBSERVICE interrupt is either not working fast enough, or not working at all.
I used the generated PBP program from EasyHID to test the interrupt logic. If I comment out the default USBSERVICE the device is not recognized, and then it works if I reinstate them. Any idea what I'm doing wrong?
Robert
Last edited by Demon; - 18th August 2006 at 18:29.
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
i can't try it here now, but here's a couple of suggestions.
Code:ProgramStart: ' gosub DoUSBIn ; remove it gosub DoUSBOut goto ProgramStart DoUSBOut: '------- Disable INT here USBBufferCount = USBBufferSizeTX USBOut 1, USBBuffer, USBBufferCount, DoUSBOut '------- Enable INT here return
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
I LOVE YOU mon maudit francais. :P
That was it, you can't mix the interrupt in there for some reason.
So now I disable the interrupt just before the GOSUB and ENABLE right after.
Robert
EDIT: By the way, you forgot the USBSERVICE in DoUSBOut.
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
Hmmm, there is still something weird in the USBSERVICE interrupt routine.
- if I comment the gosubs for In and Out it is not recognized.
- if I replace them with a USBSERVICE it works.
Something is still not right with the interrupt, the correction worked because the manual USBSERVICE kept the connection active.
Robert
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
Ok sure but.. how about...
Also be sure your Timer interupt is about every 10 ms... not much but not too fast... if it's too fast maybe USBSERVICE can't finished before another interupt. So you got nested USBSERVICE trying to do their job at the same time or close to.Code:USBSERVICE ProgramStart: pause 100 ' or else usefull stuff goto ProgramStart
Last edited by mister_e; - 18th August 2006 at 19:47.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Steve, I don't know how to check how often the USBSERVICE interrupt is occurring. The only settings I have are the oscillator and prescaler:
DEFINE OSC 48
T1CON = $11 ; Prescaler = 2, TMR1ON
I am using a 20MHz crystal with these configuration settings:
CONFIG PLLDIV = 5 ;Divide by 5 (20MHz input)
CONFIG CPUDIV = OSC1_PLL2 ;[OSC1/OSC2 Src: /1][96MHz PLL Src: /2]
CONFIG USBDIV = 2 ;Clock source from 96MHz PLL/2
CONFIG FOSC = HSPLL_HS ;HS oscillator, PLL enabled, HS used by USB
Robert
EDIT: Interesting, I added a counter in the interrupt routine and displayed it on the LCD, it only gets executed once. I'm checking now if I disable it and never re-enable it after.
Last edited by Demon; - 18th August 2006 at 19:58.
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
your pre-scaller is way too low... so interupt ocure way too fast, USBSERVICE don't have time to finish correctly.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Do you have a suggestion?
Robert
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
Uh... my calculation were wrong... (1/12000000)*65536*2='round 10mSec. ARRGGH i don't have my stuff here to compare with mine... Darrel is on-line anyway
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
NO.. let's look at that...
i remind that TiCON can be use in 16 bit or 8 bit.. i'm sure you use it in 8 bit mode now... or i missing something obvious about the 16/8 bit.. maybe just in read/write something... mmm something look weird in this line...clock source, mode or else.Code:T1CON = $11 ; Prescaler = 2, TMR1ON
Last edited by mister_e; - 18th August 2006 at 20:28.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Well yeah, I'm online. But that's not going to help much since I don't have a Clue about using the USB stuff. Just never got around to trying it before.
I'm still hoping you guys can figure it out. So that when I do get around to trying it, I won't have to work as hard.
<br>
DT
if i can finish the house-bench-lab-cleaning stuff soon, i'll have access to my stuff. I have this one working.. but i don't remind wich timer i used and how i used it... the T1CON line seems weird... clock source is still my most possible guess.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Ok, I disabled that code to disable/enable the USBSERVICE interrupt before the gosubs and now the interrupt is getting executed a LOT of times.
I can't say at what interval, but the counter is scrolling on the LCD pretty fast. The hundreds are going by just a bit faster than every second, but I still lose connection.
Darrel, how can I adjust the speed of the interrupt?
Robert
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
I'm going to solder a wire to 1 pin, blink that pin in the interrupt and connect my scope on the wire.
I don't know much about scopes, but I might be able to figure out the frequency.
Robert
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
Steve, I'm trying to figure this out using math (gotta start sometime) and I'd like to know where you got the 12000000 from.Originally Posted by mister_e
I read this link you posted in another thread:
http://ww1.microchip.com/downloads/e...Doc/41214a.pdf
And I got this formula from Tip #7:
Tosc x 4 x 65536 x prescaler
I am using a 48MHz crystal so I get this:
(1/48000000) x 4 x 65536 x 2 = 0.0109226 (repeating)
D'uh, ok, I see it now, 48 / 4 = 12, that's where you got your value. So, as you said, that interval rounds up to just over 10ms, that 'should' work.
I'm sure it has something to do with the interrupt occurring right in the middle of USB processing and interfering with the connection. I don't see what else it can be; the interrupt seems fine, the USB works.
Robert
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
Hello guys,
I am a newbie to this forum and PIC/PBP.
I am very glad to have Darrel Taylor's DT_INTS-14 compiled and work great for me.
I tried to add small routine for receiving data from usart but something start to stop working.
I posted my code below with all details remaked. Please someone find what have i done wrong.
I am still in my learning process and am scrolling. Many thanks
Cheers,
ozion
Code:'**************************************************************** '* Name : BringTogether_with_RX-USart.BAS * '* Notice : Using DT_INTS-14 * '* MCU : PIC16F877A * '* Goal : A string of data from PC via usart will interrupt * '' : the PIC from what it was doing to receive the data,* '* : filter and store received data for processing. * '* : After received the filtered data, an acknowledge * '* : will be send back to PC then return to what it was* '* : left off (and processing the received data) * '* : * '* Notes : This program was working without adding Usart RX * '* : Now '* : Clock works OK * '* : LED1 won't work * '* : LED2 won't work * '* : Usart won't work as expected. * '**************************************************************** clear define LOADER_USED 1 define OSC 8 ' Define LCD registers and bits Define LCD_DREG PORTB ' LCD Data register on PORTB Define LCD_DBIT 4 ' LCD data bits (4 bits) Define LCD_RSREG PORTB ' LCD Reset register on PORTB Define LCD_RSBIT 2 ' LCD Reset bit 2 (PORTB.2) Define LCD_EREG PORTB ' LCD Enable register on PORTB Define LCD_EBIT 3 ' LCD Enable bit 3 (PORTB.3) ADCON1 = 7 ' Set portA outputs to Digital / No ADC 'CMCON = 7 LCDOUT $FE,1 ' Initialize LCD PAUSE 200 dat_in var byte[10] ' Added for Usart receive data ack var byte ' Added for Usart receive acknowledge cntr var byte ' Added for Usart receive data storage LED1 VAR PORTD.0 LED2 VAR PORTD.3 INCLUDE "DT_INTS-14.bas" ' Required INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts INCLUDE "Elapsed_INT.bas" ' Elapsed Timer Routines ' Initialize USART ' Added for Usart receive process TRISC = %10111111 ' Set PortC.6 to output, rest to input DEFINE HSER_BAUD 9600 ' Hser baud rate RCSTA = %10010000 ' Enable serial port and continuous receive TXSTA = %00100000 ' Enable transmit and asynchronous mode ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler INT_INT, _ToggleLED2, PBP, yes INT_Handler TMR0_INT, _ToggleLED1, PBP, yes INT_Handler TMR1_INT, _ClockCount, PBP, yes INT_Handler RX_INT, _Read_USART, PBP, yes ; Added endm INT_CREATE ; Creates the interrupt processor INT_ENABLE INT_INT ; enable external (INT) interrupts INT_ENABLE TMR0_INT ; enable Timer 0 interrupts INT_ENABLE TMR1_INT ; Enable Timer 1 Interrupts INT_ENABLE RX_INT ; enable RX_Usart interrupts ; Added ENDASM OPTION_REG = OPTION_REG & $80 | 1 ; Set TMR0 Prescaler to 256, leave RBPU alone Gosub ResetTime ' Reset Time to 0d-00:00:00.00 Gosub StartTimer ' Start the Elapsed Timer Main: if SecondsChanged = 1 then SecondsChanged = 0 LCDout $FE,$C0, dec Days,"d-",dec2 Hours,":",dec2 Minutes,":",dec2 Seconds endif if Ack=1 then ' Added gosub Receive_Ack ' Added endif ' Added GOTO Main '---[INT - interrupt handler]--------------------------------------------------- ToggleLED1: Toggle LED1 @ INT_RETURN '---[TMR0 - interrupt handler]-------------------------------(Blinky Light)------ T0Count Var WORD ToggleLED2: T0Count = T0Count + 1 if T0Count = 512 then T0Count = 0 : Toggle LED2 @ INT_RETURN '//////////////////////////////////////////////////////////////////////////////////// 'Added to read Usart Read_USART: hserin[dat_in] '=========================================================================== 'The following 2 lines won't work 'hserin[wait("X"),str dat_in\5] ' Wait for X ;receive a string of characters 'hserin[wait("X"),dat_in] ' Wait for X '=========================================================================== 'Following lines send back string includes first dectect char "$" 'Example: PC sent: "12345$6789" ' PIC send back to PC "12345$" ack=0 ' clear ack cntr=0 ' reset counter while cntr<10 ' looping if (dat_in[cntr]= "$") then ' filter character "$" HSEROUT[str dat_in,cntr] ' ack=1 ' Yes found "$" cntr=10 ' get out of loop endif ' cntr=cntr+1 ' increment counter wend ' HSEROUT[str dat_in] ' send to PC 'gosub Receive_Ack ' This doesn't works it does not call Receive_Ack @ INT_RETURN Receive_Ack: if ack=1 then HSEROUT ["got it:"] HSEROUT[str dat_in] ' Send dat_in received string endif ack=0 return '//////////////////////////////////////////////////////////////////////////////
Last edited by Darrel Taylor; - 7th September 2006 at 06:20. Reason: added [code][/code] tags
Hi ozion,
First rule of interrupts, Never Wait for anything.
Interrupt handlers should execute as fast as possible, and exit as soon as possible.
With 18F's you can get away with using HSERIN/HSEROUT with Waits and Pauses, by putting them in a LOW priority interrupt handler. But with the 16F's, you don't have that option.
If you want to use interrupts to receive serial data on 16F's, then you should only grab 1 byte at a time then exit. You can keep track of how many bytes have been received and set a Flag when finished so that it can be dealt with in the Main loop. Then you can HSEROUT to your hearts content.
Otherwise, do all the serial stuff in the main loop, RX and TX. The main loop should run fast enough to catch everything. And the interrupts will continue on like they should.
HTH,
Darrel
Hi Darrel,
Thanks for reply, I will try that your suggestion.
Regards,
ozion
Hi Darrel,
I have just started to use the instant interrupts. Previously i had used 8051 and the bascom compiler. I wanted to set priority to the various interrupts similar to the 8051. in the 8051 the lower priority interrupts can be interrupted by the higher priority interrupts. I can see that we can set priority only in 18F series of pic and not in 16F.
Can we not have priority in 16F pics?
Again i think among the high priority interrupts, those interrupts we would like to service it immediately we place their interrupt handler at the top, but i dont think by doing that we can exit the current high priority interrupt service routine to go and attend another interrupt whose interrupt handler is placed before the current executing interrupt's handler. Meaning to say nesting of interrupts is not possible here. One has to wait until the current ISR is finished to enter into another ISR.
Am i right in saying that Darrel? If that is the case then for any time measuring program we must make sure that the ISR of each of the interrupts are so small that they dont cause a large error in measurement.
Please comment.
Raghunathan
That's correct.
No priorities for 16F's. It's a limitation of the PIC's, not the Instant Interrupts.
>> then for any time measuring program we must make sure that the ISR of each of the interrupts are so small that they dont cause a large error in measurement.
Unless you use the capture mode of a CCP module, also true.
But if you switch to 18F's, the problem goes away.
<br>
DT
Dear readers,
Although DT_INTS-14 and Multi_SPWM working great if using seperate, I can't get them running combined ....
I included them together with ReEnterPBP.bas getting errors like
ERROR Line 10: Redefinition of VAR. (Multi_SPWM.pbp)
ERROR Line 13: Redefinition of VAR. (Multi_SPWM.pbp)
ERROR Line 14: Redefinition of VAR. (Multi_SPWM.pbp)
ERROR Line 18: Redefinition of VAR. (Multi_SPWM.pbp)
ERROR Line 20: Redefinition of VAR. (Multi_SPWM.pbp)
(if the order I included them is changed I got about same errors by DT_INTS-14)
I guess it's because same variables (psave, wsave etc) used in both of them but I don't have the ASM experience to solve the problem and would appreciate any advise/tips.
Also tips to use another way to interrupt (INT_INT on RB0) Multi_SPWM are welcome...
Thank you !
Willem
Bookmarks