PDA

View Full Version : PM Asembler and Melab U2 Programmer Problems with PIC16F1939



rsocor01
- 2nd January 2011, 04:42
Hi,

Here is another question regarding these PIC16F193x chips. First of all, let me say that this chip is supported with the new PBP 2.60 version. But, I couldn't use the PM asembler that comes with PBP. I got the following error and was forced to use MPASM.

5043

This is not really an issue since using MPASM is a workaround and should be fine. But, isn't PM supposed to work with all the 16F series chips? It was my understanding that MPASM was only required for the 18F series.

Now, it comes the real problem :confused:. When I try to program my 16F1939 using my Melab U2 Programmer, the software can not find the chip. So, I went ahead and upgraded the firmware hoping to get support for this new chip.

5044

But, still the programmer software doesn't support this chip. Is there something that I'm missing here? Or, am I getting forced to buy the PickIt3 programmer :)?

Thank you for your help,

Robert

bogdan
- 2nd January 2011, 15:50
I have the pic16F1939 on mine (ver 4.32)

5045

mister_e
- 2nd January 2011, 19:20
There is NO good reason to use PM as far as I know. Just stick to MPASM. You have much more great "hidden" features in...

bogdan
- 2nd January 2011, 20:23
welcome back ! :)

rsocor01
- 2nd January 2011, 23:24
Bogdan,

Tonight I will check to see what software version I have. I bought my U2 programmer about two years ago, so it is probably an old version. I need to research this issue a little bit more.

Mister_e,

It is very nice to see you back :). I have a program >8000 words that I developed using PM. This program uses interrupts on a PIC16F727 to read values for a built-in capacitance touch sensor. However, if I use MPASM the sensors don't work properly. I suspect it has to do with different interrupt intervals if I use MPASM, but I haven't tested this yet. This is the reason why I use PM for my touch sensor projects.

Robert

mister_e
- 3rd January 2011, 00:12
Or it's working as design with MPASM, but have problem with PM, but... ya never know.

Do yourself a big favor, isolate the problem, keep the ISR and a simple short and sweet main loop, see if the problem's still there.

Usual Convention: Keep the ISR as short as possible.


Get rid of PBP interrupt and use ASM one, or DT.

Maybe not a bad idea to make sure you're using the latest MPASM version.

rsocor01
- 3rd January 2011, 02:35
Bogdan,

I have an old software version 4.23. In Melabs.com they have a free download for the latest Beta v4.32 software. I will install it and will post back with results.

Mister_e,

Yes, I know that I have to fix that problem with the interrupts to make the sensors work properly with MPASM. Now, I am using ON INTERRUPT GOTO ISR to handle the ISR. There are many lines of code that need to get done in the ISR routine. So, if I have many lines of PBP in the ISR routine, what method should I use?

Should I go with something like this?

@myint ; create myint label
.......
@ retfie FAST ; Return with 'auto restore' of WREG, STATUS and BSR


Or, should I do something like this with DTs interrupts?


INCLUDE "DT_INTS-14.bas" ' Base Interrupt System
INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts

ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler TMR0_INT, _MyInterrupt, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM

@ INT_ENABLE TMR0_INT ; enable Timer 0 interrupts

.....

MyInterrupt:
.....
@ INT_RETURN

mister_e
- 3rd January 2011, 03:55
If you have PBP lines in your ISR, I'd say go for your second example.

What kind of interrrupt it is? Remember that ON INTERRUPT will jump in your ISR ONLY after finishing a x current job. So if you have, say PAUSE 5000, in your main loop, it may take up to 5 secondes to jump in the ISR (assuming your main loop is actually doing the PAUSE). Maybe why your sensor doesn't work that good. Now why better on PM than MPASM, I don't know.

rsocor01
- 5th January 2011, 00:28
The new U2 programmer software version supports all the PIC16F193x. So, I was able to program my 16F1939 :).


What kind of interrrupt it is? Remember that ON INTERRUPT will jump in your ISR ONLY after finishing a x current job. So if you have, say PAUSE 5000, in your main loop, it may take up to 5 secondes to jump in the ISR (assuming your main loop is actually doing the PAUSE).

The interrupts that I'm using are kind of complicated (at least for me :(). To make the Capacitive Sensors to work a value needs to be read from TMR1L and TMR1H together. This would tell you if the sensor was touched or not. However, the interrupt overflow is determined by TMR0. This is the way is done in the Application Notes. The interrupt settings for a 16F727 look something like this and it works,


OPTION_REG = %11000011 'Bit 2-0, 110= prescaler rate 1:16 (TMRO INTERRUPTS EVERY 1.024 mSec)
T1CON = %11000101 'Timer1 initialization
T1GCON = %11100001 'Timer1 gate init /Toggle Mode/TMR0 time base
PIR1.7 = 0 'Clear Gate Interrupt Flag. Timer1 gate is active (TMR1GIF BIT)
PIE1.7 = 1 'Disable the Timer1 Gate Acquisition complete interrupt (TMR1GIE BIT)

TMR0 = 0 'TMR0 overflows every (256-TMRO)*(Prescaler rate)(4*(1/16)uS)=1024uSec.

ON INTERRUPT GOTO ISR
INTCON = %10100000 'Enable Interrupts

DISABLE 'Disable further interrupts
ISR:
T1CON.0 = 0 'Stop/Clears Timer1 before reading TMR1

....

"Read TMRL and TMRH"

....

TMR1L = 0 'Reset Timer1
TMR1H = 0
T1CON.0 = 1 'Restart/Enable Timer1 (TMR1ON BIT)
TMR0 = 0 'RESET TMR0 TO 0
INTCON.2 = 0 'Re-enable TMR0 interrupts. Bit 2, 0= clears overflow, 1= overflow ocurred

RESUME 'Return to main program

ENABLE 'Enable interrupts

Darrel Taylor
- 5th January 2011, 01:46
Byte_Butcher was working on Capacitive Touch on a 727 with DT_INTS here ...
http://www.picbasic.co.uk/forum/showthread.php?t=10578&p=71611#post71611

I'm not sure what needs to be changed for the 1939, but it's probably a good start.

DT

rsocor01
- 5th January 2011, 12:26
Darrel,

My program is working fine with the 16F727 and the 16F1939 as it is. But, I think it will run a lot smoother if I use the DT interrupts :D.

The amount of time that the chip takes between ISRs is very critical for the CSM (Capacitive Sensing Module) to work properly. So, please excuse my next dumb question :confused:. Can I say that I have a much better control of the interrupt intervals using DT interrupts than using ON INTERRUPT? And why?

Robert

mackrackit
- 5th January 2011, 14:07
ON INTERRUPT will take care of the interrupt when it has time. A flag is set when the interrupt happens and is executed between instructions. If you have a long PAUSE the interrupt will not be serviced until the PAUSE is finished.

ASM interrupts will take care of the interrupt immediately. Everything the chip is doing at the moment has to be saved then returned to. And the ISR is coded in ASM.

Read the interrupt section in the back of the manual.

DT's instant interrupts will make even a PBP type work like an ASM type.

rsocor01
- 6th January 2011, 04:11
ON INTERRUPT will take care of the interrupt when it has time. A flag is set when the interrupt happens and is executed between instructions. If you have a long PAUSE the interrupt will not be serviced until the PAUSE is finished.

ASM interrupts will take care of the interrupt immediately. Everything the chip is doing at the moment has to be saved then returned to. And the ISR is coded in ASM.

Read the interrupt section in the back of the manual.

DT's instant interrupts will make even a PBP type work like an ASM type.

Dave,

Thank you. Your answer was really helpful. I have a lot of reading to do to understand better how these different interrupts work.

Robert