For the clock signal use CLC. That should be able to generate that frequency. If that works then would this help?
We have a machine that is imported from China that uses a number of LED seven segment displays each element having a shift register to 'decode' the display elements. The final display in the chain often flickers and flashes. Looking at the timings from the host I'm surprised things work at all, the clock, data and chip select times all vary by some quite large percentages. I thought I could 'capture' the clock and data streams in a PIC and then re-transmit them slightly slower but with more stable...
We have a machine that is imported from China that uses a number of LED seven segment displays each element having a shift register to 'decode' the display elements. The final display in the chain often flickers and flashes. Looking at the timings from the host I'm surprised things work at all, the clock, data and chip select times all vary by some quite large percentages. I thought I could 'capture' the clock and data streams in a PIC and then re-transmit them slightly slower but with more stable...
The GCB code.
Hi Fabrice, I attach here the core components needed for the update system to work, extract them on your installation directory so you can be sure the next update will work as expected. this in case that windows defender prevented any of this files to deploy correctly. And thank you for keep us informed. Angel
Please find attached a revised XML. This is updated to revised the TMR0, TX1 and TX5. The XML is the database. No application changes needed. Replace the existing XML in this directory - C:\GCstudio\ppstool\devices
The GCB code.
Yes! We're down from a two chip to a one chip solution for outputting High resolution audio! I got i2S working using two timers+PWM making the logic pattern and an interrupt starting/syncing the audio bitstream blocks off. Inside the ISR, after the bitbanging, the sample data handling is done (for next bunch of 16bits). Using the faster clock i2s 64bit format (2.048MHz for 32kHz sampling freq), sending one channel of 16bit data, there is about 70% of processing time left for handling samples or whatever....
Great news
For some unknown reason after the last update, Timer0 and PWM (out on pins) now works with both running at the same time (also on an unmodified curiosity board). Before the update I had tested on the fewer pins version 18F27Q84 and it had not issues with this (same code, just changed to the appropriate pins for this chip).
For some unknown reason after the last update, Timer0 and PWM (out on pins) now works with both running at the same time. Before the update I had tested on the fewer pins version 18F27Q84 and it had not issues with this (same code, just changed to the appropriate pins for this chip).
PPS tool and 18F57Q84: TMR0 output pins in the menu are RBx, RCx, RFx The data sheet says only Ports C and F for 48-pin devices. TX1 and TX5: Pins in the menu are RBx, RCx, RFx The data sheet says Ports C and F for 48-pin devices. TXDEx seems to have too many port options also.
Great advice. Thank you.
Hello, I just get update 1.0128, but blocked by Windows Defender. I added an exclusion for GCBasic.exe. Get following files blocked during update: C:\GCstudio\PICPgm\inpoutx64.sys C:\GCstudio\GCstudio.exe I saw also something for minidump, but no error message in the history available.
Good bye 18F57Q84 curiosity board with the insane pinout, close to unreadable print and missing port pins. Hello 18F27Q84 on a breadbord with a readable sticker. I should have done this long ago!
There may be a hardware issue with the 18F57Q84. When changing to another 18F57Q84 curiosity board the outputs just dies when I try to output both Timer0 and PWM at the same time. On their own they each work as expected. On one board it works very slightly. -Ports are toggling on and off, so it seems like a border case. While experimenting getting Timer2+PWM and Timer4+PWM setup in assembler, I got it working on FOSC/4. I then found that it would neither run on HFINTOSC nor MFINTOSC. If I ran the...
There may be a hardware issue with the 18F57Q84. When changing to another 18F57Q84 curiosity board the outputs just dies when I try to output both Timer0 and PWM at the same time. On their own they each work as expected. On one board it works very slightly. -Ports are toggling on and off, so it seems like a border case. While experimenting getting Timer2+PWM and Timer4+PWM setup in assembler, I got it working on FOSC/4. I then found that it would neither run on HFINTOSC nor MFINTOSC. If I ran the...
Can you try one of the many Help formatted output formats. These are published and mantained.
one of the many things i tried with gcbasic was a thermometer using an LM35;i never managed to figure out the maths involved,and i seem to have lost my code which i was playing with.for the life of me i can't find an example gcb routine using the LM35 pleeeese can you post the code you got to work? i've read through all the 4meg html with no luck many thanks
There may be a hardware issue with the 18F57Q84. When changing to another 18F57Q84 curiosity board the outputs just dies when I try to output both Timer0 and PWM at the same time. On their own they each work as expected. On one board it works very slightly. -Ports are toggling on and off, so it seems like a border case. While experimenting getting Timer2+PWM and Timer4+PWM setup in assembler, I got it working on FOSC/4. I then found that it would not run on HFINTOSC and MFINTOSC. If I ran the 18F57Q84...
There may be a hardware issue with the 18F57Q84. When changing to another 18F57Q84 curiosity board the outputs just dies when I try to output both Timer0 and PWM at the same time. On thir own they both work as expected. On one board it works, very slightly by toggling the ports on and off, so it seems like a border case. While experimenting getting Timer2+PWM and Timer4+PWM setup in assembler, I got it working on FOSC/4. I then found that it would not run on HFINTOSC and MFINTOSC. If I ran the 18F57Q84...
There may be a hardware issue with the 18F57Q84. When changing to another 18F57Q84 curiosity board the outputs just dies when I try to output both Timer0 and PWM at the same time. On thir own they both work as expected. On one board it works, very slightly by toggling the pots on and off, so it seems like a border case. While experimenting getting Timer2+PWM and Timer4+PWM setup in assembler, I got it working on FOSC/4. I then found that it would not run on HFINTOSC and MFINTOSC. If I ran the 18F57Q84...
I have found chatgpt useful to write segments of code but it uses registers and binary to set port direction and function etc. As far as I can tell chatGPT hasn't been extensively trained on the high level gcbasic commands we are so familiar with. So I made a single 4MB html file by merging all the command syntax html entries (complete with examples) in the gcbasic CHM file which is attached to this post. The single html file was uploaded to chatgpt and I asked it to parse the file and commit all...
Thank you once again. It works a treat. I put the first part of the routine above my main program as: ' ============================================= ' Enable Interrupts sor Sleep Function ' ============================================= // Both edges (most common for buttons/encoders) IOCBP6 = 1 ;Required IOCBN6 = 1 ;Required On Interrupt PORTABChange Call Handle_IOC ' Link IOC interrupt to subroutine Main: ;----- start main******* and a Sub called Handle_IOC .... Calling up that Sub routine when...
Try this following to wake. // Both edges (most common for buttons/encoders) IOCBP6 = 1 IOCBN6 = 1 ' ============================================= ' Enable Interrupts ' ============================================= On Interrupt PORTABChange Call Handle_IOC ' Link IOC interrupt to subroutine // code, lots of it. ' ============================================= ' Interrupt Service Routine (ISR) ' ============================================= Handle_IOC: If IOCBF.6 = 1 Then ' Check if RB6 caused the...
Yes, that is a problem. it goesn't go to sleep. It becomes Comatosed!. I need it come back to life on pressing the encoder switch on PortB.6 The code is below - Thank you
What event will wake the chip? That may help answer.
So I don't use any of the code instructions as befpre with the 10F202 and 12F508 ? Thats magic - Thank you.
So I don't use any of the code instructions as befpre with the 10F202 and 12F408 ? Thats magic - Thank you.
Just enter the command sleep
Many moons ago you helped with some code you wrote for me to send a PIC29F202 into sleep. The code you wrote was: SysBYTETempA = On_signal 'Clear the port change reset flag Set GPWUF off movlw B'01001111' 'This is assembler. :-) option 'Return to sleep wait 3 S sleep nop The code has been recycled many times by simply changing the £On_signal " line. the PIC16F18346 I'm using in this latest project doesn't want to know this and spits it out as if it were a nasty taste. Having resolved all the project...
In the curiosityboard one needs to cut tracks to a crystal in order to use RA6 and 7 as ports. I did that earlier today. Now looking in a microscope, there was a extremely thin trace left. That is why I did not get any Fosc out of RA6. Strangely enough, when RA6 was freed, then the toggling of the other ports stopped! How can the crystal on RA6 and RA7 have anything to do with this??? Still not convinced I have power toggled several times. Yes the outputs just keeps going without interruptions. What...
In the curiosityboard one needs to cut tracks to a crystal in order to use RA6 and 7 as ports. I did that earlier today. Now looking in a microscope, there was a extremely thin trace left. That is why I did not get any Fosc out of RA6. Strangely enough, when RA6 was freed, then the toggling of the other ports stopped! How can the crystal on RA6 and RA7 have anything to do with this??? Still not convinced I have power toggled several times. Yes the outputs just keeps going without interrutions. What...
The whole 18F57Q84 seems to reset or something(?). If add turning A.6 on, then it too starts going: on / off (high Z) / on / off (high Z) I am not doing anything on PORTA other than that. Just: DIR PORTA OUT PORTA.6=1 If found that out when trying #config CLKOUTEN = ON (or OFF) to see if I could see what happened to Fosc. That didn't work, no clock on A.6, but if I set it on, then I could see that it would not stay high.
Disabling the PPS for timer0 the problem remains (no change). If I don't StartTimer 0, then PWM is fine. If I StartTimer 0, both outputs starts going on / off (high Z) / on / off (high Z). (There is nothing more connected to the 18F57Q84 curiosity board than USB supply and oscilloscope. The only pins sensitive to touch are the outputs when they go into high Z state)
Disable the PPS for timer0. If ok. Then, this is probably cross talk - revise your circuit.
Would the tutorial for closest to Q84 be this one? PT14: PIC18FxxQ24 chip Family - Using the PIC18FxxQ24 with PWM - 6 ways What I am looking for in the end of this experimentation, is having a square wave out on a pin, with a frequency of HFINTOSC/4/8 or HFINTOSC/4/10 etc. I could use some other source (that is jitter free), but if I want one to be HFINTOSC/4/10, then I guess that I need to go with one the timers (not Timer0 since it already in use). Too many options. Always somehting to complain...
Both PWM and Timer0 works separately (by commenting out (//) the parts of code). When combined the on and off 4ms periods starts. If I remove the Timer0 chunk, then The PWM is solid. For Timer0 to work then I have to remove both PMWOn and RC2PPS, CCP1PPS from Sub InitPPS = I need to remove both PWMOn and the PPS stuff. I tried to have a look in the asm when doing the PWM only, but I did not see Timer0 being involved. When running both, Timer0 and Timer2 are in the asm, but I am too bad at asm to...
Check the ASM. Does the PWM work when this is setup ( therefore, no timer0 code ) Does the timer0 code work when jn PWM code? I cannot test at the moment.
Trying to output Timer0 at the same time, Both outputs for 4ms, then the both outputs are floating (like inputs) for 4ms and then outputs again . Isn't the PWM using Timer 2? What is this about? What is the conflict? #CHIP 18F57Q84, 64 #OPTION Explicit // PIC PPS Tool version: 0.0.6.5 #startup InitPPS, 85 #define PPSToolPart 18F57Q84 // Sub InitPPS // Module: CCP1 RC2PPS = 0x0015 // CCP1 > RC2 CCP1PPS = 0x0012 // RC2 > CCP1 (bi-directional) // RF3PPS = 0x0039 // TMR0 > RC0 // 28/40-pin PORT B,C /...
Check out the tutorial for PWM for these chips. There are many options and they are explained in tgr video and associated PowerPoint.
Actually I did yesterday and I didn't even understand how get the fixed mode up and running. What was all that code doing??? And what about "It will emit the signal for 10 seconds, then stop."?? How?? Where?? Turns out that was not true. It does not stop. Ok. So I tried again, cleared the weeds and this is the simple code for fixed mode on 18F57Q84: Correct? I don't know but it does output 1 MHz on PORTC.2. #CHIP 18F57Q84, 64 #OPTION Explicit // PIC PPS Tool version: 0.0.6.5 #startup InitPPS, 85...
Check the Q84 PwM demos.
I tried bunch of stuff for a good while, including some demos and last AI examples. No luck. It's just plain dead. No output on PORTC.2 The more I read in the docs the more confused I get. What is wrong or missing? I found PWM11 (18F57Q84) in the PPS tool and tried with that.-Nope. AI suggested PWM1-didn't work. #chip 18F57Q84, 64 #option Explicit // PIC PPS Tool version: 0.0.6.5 #startup InitPPS, 85 #define PPSToolPart 18F57Q84 Sub InitPPS // Module: PWM1_16BIT RC2PPS = 0x0018 // PWM11 > RC2 End...
Now for today's aggravation. The problem I'm having is reading the Pulsein signal output very occasionally throws 0 (zero) This can be seen in screenshot, Capture4 below. I'm driving the input wit a 1kHz signal from a signal generator The input is preconditioned with two gates of a 74HC14 Hex Inverter Schmitt Trigger. I need to be able to pick up the lack of coolant flow when the Pump and Spindle Motor VFD is on. This is the code I have so far. I think I need something that ignores the missing pulses...
Now for today's aggravation. The problem I'm having is reading the Pulsein signal output very occasionally throws 0 (zero) This can be seen in screenshot, Capture4 below. I'm driving the input wit a 1kHz signal from a signal generator The input is preconditioned with two gates of a 74HC14 Hex Inverter Schmitt Trigger. I need to be able to pick up the lack of coolant flow when the Pump and Spindle Motor VFD is on. This is the code I have so far. I think I need something that ignores the missing pulses...
This has me really baffled ! it's working fine now - I don't understand... Don't believe in Code Gremlins and fairy's
Im having a problem using the Pilsein command. Im' almost sure I have written the instruction an syntax correctly. What is happening is the program runs properly without the "Pulsein Flow, FlowRate, mS" line but as soon as I un-comment it, compile and upload it, it freezes or halts the the loop. the full program is attached below. define Flow PORTC.3 Dim FlowRate as WORD Main: ;----- start main******* Do ; FlowRate = 0 ; Count = Count + 1 If ENCODER_SW = 0 Then Wait 400 mS Wait until ENCODER_SW =...
Im having a problem using the Pilsein command. Im' almost sure I have written the instruction an syntax correctly. What is happening is the program runs properly without the "Pulsein Flow, FlowRate, mS" line but as soon as I un-comment it, compile and upload it, it freezes or halts the the loop. the full program is attached below. define Flow PORTC.3 Dim FlowRate as WORD Main: ;----- start main******* Do ; FlowRate = 0 ; Count = Count + 1 If ENCODER_SW = 0 Then Wait 400 mS Wait until ENCODER_SW =...
I have eventually managed to resolve the Encoder issues in my project. I apologise in advance to the Author of the encoder.h include file, Thomas Henry but my 'Cack-Handed Fix' involved modifying a few variables in the include file. I'm still unsure as mathmatical equation but changing two values in a simple IF statement gave me the desired effect of an elevated minimum value preventing a negative overflow which was causing a major headache when storing the value to EPPROM Now fhe next couple of...
I have eventually managed to resolve the Encoder issues in my project. I apologise in advance to the Author of the encoder.h include file, Thomas Henry but my 'Cack-Handed Fix' involved modifying a few variables in the include file. I'm still unsure as mathmatical equation but changing two values in a simple IF statement gave me the desired effect of an elevated minimum value preventing a negative overflow which was causing a major headache when storing the value to EPPROM Now fhe next couple of...
I have a working solution with just one extra PIC18F57Q84 (GCB file attached above). It takes the parallel data and outputs i2s (incl flipping the MSB as per i2S standard). There is a requirement when the sender is allowed to update the parallel port to avoide glitches, otherwise I see no issues so far. Up to around 50kHz sample freqeuncy is possible, but it may require some code adustement removing or adding nops. I have a plan for making this externally selectable through setting pins, unless I...
Great, thumb up for your project! I've never tried that, but maybe two shift registers could help, e.g. of type 74HC166.
A quick look as I do not have the setup you have. And, I am not totally sure how the encoder routines works. But, you know encode() will set 'value' to 0 to 16383, so call the method then scale to the constraints you want of 100, 460. encoder(value, 100, 460) ;between 100 and 460, inclusive value = Scale ( Value, 0, 16383, 100, 460)
I must a have a different source file to what you are using. If yours compiles then we are not working on the same source file.
I don't have a clue what is causing the problem. DSDATA is the byte which handles the Digital Temperature Sensor (DS1822) what happens if you Comment it out as it is not needed to resolve the encoder issue (just a thought)
I cannot get the source ( with the .h instaled ) to compile. An error has been found: Spindle Motor Intercooler.gcb (85): Error: SCRIPT/Constant: HI2C_DATA cannot be reassigned to PORTC.1 and, this will not compile. Dim DSDATA, as Byte
I cannot get the source ( with the .h instaled ) to compile. An error has been found: Spindle Motor Intercooler.gcb (85): Error: SCRIPT/Constant: HI2C_DATA cannot be reassigned to PORTC.1
Yes it is in the include Encoder.h Line 82 refers. Thomas has written up an explanation on line 31 how it works. It states the minimum is '0' and the maximum is 16383. I need it to start at 100 which works out at 10˚C when divided by 10 and tops out at 46˚C What happens below 10˚C it starts to display weird and wonderful decimal digits and doesn't store the value to the EEPROM correctly. In layman's terms it goes boobs up!
I stand to be corrected but I think it is handled by the include Encoder.h by Thomas Henry 6/7/2014 I'm not too sure how it works (Once again well above my pay scale) but it handles a rotary encoder really well particularly the RUNCCI-YUN KY-040 Rotary Encoder Module from Amazon. Once again I have attached the encoder zip below
I cannot find a sub() or function() called encoder(). Help me.
I hooked this Parallel to i2S converter up to DAC. A sine plays nicely, coming from another 16F57Q84 clocked by an external interrupt from the i2S converter (which is clock master). My Musicbox slave to external interrupt, chokes when more than 6 voices plays (it slacks a bit on load and then probably does not deliver data in time = horribly sounding bit errors), but it sounds fine with a limited number of voices. I will leave it at that. I have other ideas where to use an i2S DAC = HQ 16-bit audio....
Many Thanks Evan
I will take a look for you.
I have an idea of a sampler using two PIC18F27Q84 and an i2S Audio DAC. Placing the two PICs side by side like this makes easy to connect the two PICs together.
After some testing, mistakes, testing again I'm getting a hang of bit banging. I managed to get i2S to an audio DAC from 16-bit parallell data. On a PIC18F57Q84 @ 64MHz it can handle up to 48kHz sample frequency. My testprogram is now running at 32kHz, but it is easy to get it to 48kHz by removing triplets of nops and fine tuning downwards slighty with OSCTUNE.
I have been along this road in the past but through one thing and another (usually health issues) I had to put it aside. The problem I'm having is with the rotary encode limitation rrange. This instruction line is responsible (I think) encoder(value, 100, 460) ;between 100 and 460, inclusive Whilst the value of 460 stops the upper value from going above 460' I don't seem to be able to work out how to stop it from going below 100. I have put the entire code in a zip file below
I have been along this road in the past but through one thing and another (usually health issues) I had to put it aside. The problem I'm having is with the rotary encode limitation rrange. This instruction line is responsible (I think) encoder(value, 100, 460) ;between 100 and 460, inclusive Whilst the value of 460 stops the upper value from going above 460' I don't seem to be able to work out how to stop it from going below 100. I have put the entire code in a zip file below
I hooked this Parallel to i2S converter up to DAC. A sine plays nicely, coming from another 16F57Q84 clocked by an external interrupt from the i2S converter (which is clock master). My Musicbox slave to external interrupt, chokes when more than 6 voices plays (it slacks a bit on load and then probably does not deliver data in time = horribly sounding bit errors), but it sounds fine with a limited number of voices. I will leave it at that. I have other ideas where to use an i2S DAC = HQ 16-bit audio....
Just sending byte variables to the PORT looks jitter free on my 350MHz 1GSa/s oscilloscope. No glitches to be seen (18F57Q84), so I guess it the safest and fastest way for my project. I will see what happens when I hook it up to a DAC.
Without #option the output port WILLL always be set low priority to being set high. This will look like jitter on a scope. But, it may be ok/acceptable with your use case.
It is actually one instrucktion cycle slower with #Option volatile LATC.2. If I turn it off 3 instructions, if I turn it on 4 instructions. Measuring at the outputs. Also I can not follow protocol, updating writing bitbanged clock cykles at the same time as the value from PortF.6 So I guess my current code is pretty much optimal(?). //With: #Option volatile LATC.2: ;LATC.1 = PortF.6 btfss PORTF,5,ACCESS bcf LATC,1,ACCESS btfsc PORTF,6,ACCESS bsf LATC,1,ACCESS // Without: #Option volatile LATC.2:...
This is faster. Option volatile LATC.2 LATC.2 = PortF.6
Maybe I simplified my example too far for it to be understandable.... This is about a parallel to serial interface. So different data bits/pins are sequentially read, combined with 2 clockbits generated from a pattern. I choose from a sequential pattern, one of four variables containing clock states to output (two bits/pins = four combinations) and which datain pin to sample and insert into the variable. Then I send the variable (all three bits) to the PORT in one BANG! BBang__D00.2 = PortF.6 LATC...
and, in the new simulator LATC.0 is cleared as expected.
The ASM clears the LATC.0 bit. And, there is no concept in ASM of simultaneously. Use can use CLC - that could.
That does not change LATC.0 to zero? //I have LATC=b'00000001' //I need to do SIMULTANEOUSLY: LATC.2 = PortF.6 LATC.0 =0 //If LATC.2=1 then the result is: LATC=b'00000100'
This may be faster #Option volatile LATC.2 LATC.2 = PortF.6
I need to sample PORTF.6 and write its state to LATC.2, simultaneously keeping LATC.1 low and setting LATC.0 low. //LatC is b'00000001' DIM BBang__D00=b'00000000' //The below takes 5 instructions, can it be made in less? BBang__D00.2 = PortF.6 LATC = BBang__D00 //If LATC.2=1 then I get LATC=b'00000100' etc = ok I have turned and squeezed and this is the most effective solution I could come up with. For my planned needs it is just about what I need, so really its fine. -Still I can't but wonder if...
Hi, I have collect together some files here that I believe are not uninteresting for use with GCB. It's about a CDC bootloader for the PIC16F145x chips, whose USB functions can also be used for custom applications. The bootloader appears with a COM port in the Windows Device Manager. Since almost all programming languages can access COM ports, it's relatively easy to write PC applications that can communicate with the own program on the chip. Here's the background to my project: About 12 years ago,...
I tested again. As well as the 0x00 one cycle trick, it (as I wrote) does a 0xFF one cycle trick and setf is emitted (the sequence gets shorter by one bit compared to other numbers). It was just that in the asm that you examined there were no 0xFF literal being used in the loop. I also tested sending two other literal values after each other to se if this would trigger the cleverness (maybe due to remining in some register). It doesn't. So it seems that 0x00 and 0xFF are the only ones who are handled...
I tested again. As well as the 0x00 one cycle trick, it (as I wrote) does a 0xFF one cycle trick and setf is emitted (the sequence gets shorter by one bit compared to other numbers). It was just that in the asm that you examined there were no 0xFF literal being used in the loop. I also tested sending two other literal values after each other to se if this would trigger the cleverness (maybe due to remining in some register). It doesn't. So it seems that 0x00 and 0xFF are the only ones who are handled...
I didn't suggest changing the behaviour of the compiler! -For more than one reason. Hopefully a search on the subject will now lead to this thread and clarify things if someone else should wonder.
The only way would be change the behaviour of the compiler and that is a lot of work. :-(
Yes, I have changed to using LATC, it is just that I opened this code from yesterday and generated the asm. I figured that there was some clever short cut somewhere, but could not grasp the logic and since I assumed wrongly, then I ended with one wheel in the ditch and lost traction for a bit. Making a long chain of pattern involving more than one pin changing simultaneously and the need for timing being constant, independent of the values written as in this case that cleverness is a disadvantage....
Thanks for sharing the ASM from "Timing mystery writing two pins.gcb"—this nails down exactly what's happening. Key part of the generated loop: SysDoLoop_S1 clrf PORTC,ACCESS ; ← 1 cycle (for 0x00) nop nop nop movlw 1 movwf PORTC,ACCESS ; ← 2 cycles (for 0x01) nop nop nop nop ; ← your extra NOP here clrf PORTC,ACCESS ; ← back to 1 cycle nop nop nop nop movlw 3 movwf PORTC,ACCESS ; ← 2 cycles (for 0x03) nop nop nop nop bra SysDoLoop_S1 The reason for the timing difference: When you write PORTC = 0...
Thank you. I think I can see clearly what happens on my oscilloscope. Even when running the PIC at 64MHz I can see a one cycle difference. For even sharper edges, I am running the PIC at 1MHz... I had gotten the info from some forums that only setting bits were always one cycle, but clearing was two. From that I tried to compensate with nops. The more I fiddled, the more confused I got. I then turned to AI and got conflicting info (for this particular chip) and it didn't exactly help. I think I placed/imagined...
Thank you. I think I can see clearly what happens on my oscilloscope. Even when running the PIC at 64MHz I can see a one cycle difference. For even sharper edges, I am running the PIC at 1MHz... I had gotten the info from some forums that only setting bits were always one cycle, but clearing was two. From that I tried to compensate with nops. The more I fiddled, the more confused I got. I then turned to AI and got conflicting info (for this particular chip) and it didn't exactly help. I think I placed/imagined...
This is a reasonable observation based on your experiments with the PIC18F57Q84, but it's likely not a general "exception" for 0x00 / 0xFF specifically—rather, it's tied to how the compiler generates assembly for literal constant values versus variables or more complex expressions. And, this is specific to your chip, other microcontrollers may or may not behave the same as each chip family has specific instructiions. In GCBASIC when you write something like: PORTC = b'00000000' ' or 0x00 or PORTC...
Or store the values in variables, then it is always two cycles. It seems that using 0x00 or 0xFF are exceptions that set the ports in one cycle. (This may be true for words as well).
So if set an unused pin, avoid all zeros or ones, I get consistency, it seems. I may lose a cycles here and there, but it gets much easier to handle the results (timing). #Chip 18F57Q84, 1 #Option Explicit OSCTUNE=8 Do LATC = b'10000000' nop nop nop LATC = b'10000001' nop nop nop LATC = b'10000000' nop nop nop LATC = b'10000001' nop Loop
So if set an unused pin, I get consistency, it seems. I may lose a cycles here and there, but it gets easier to handle the results (timing). #Chip 18F57Q84, 1 #Option Explicit OSCTUNE=8 Do LATC = b'10000000' nop nop nop LATC = b'10000001' nop nop nop LATC = b'10000000' nop nop nop LATC = b'10000001' nop Loop
I just realised it could be writing anything else than 0000000 then it takes one cycle longer and I cured it with a nop before it? I thought that setting port pins should be one cycle.(?) So writing anything else but 0x00 or 0xFF means two cycles?
I have tried LAT and is getting the same result. I just tried it again. Same result.
You should be using LAT not PORT ? But, do check the ASM to see if the compiler is already handling as LAT.
Trying to solve a problem with timing when setting more than one port. This is harder than I thought, since timing is changing depending on what is written to the port before. I thought I had a grasp on it, but then this comes along. To demonstrate my problem I coded a symmetric square wave. If I set PortC.1 like in the code below, then I have to remove one nop to get the same result. What is the reason behind this? #Chip 18F57Q84, 1 #Option Explicit Do PORTC = b'00000000' nop nop nop PORTC = b'00000001'...
The installer looks safe. I have just downloaded here. Create a local whitelist for the installer. https://www.virustotal.com/gui/file/33efa41efad45269b8b6e4ce9105d007aa5714c20175462a5aeb72800b143c6b this shows that one minor company solution as flagged the EXE but this is of no concerned.
Hi, I went to download the latest gc studio installer, and straight away norton removed it before I had chance to do anything. Worse still, it's removed my gcstudio folder and all its contents. Any help would be gratefully received john
I had these needs, and they can be easily managed using bit masks. For some lighting effects, I had some pins on a port used as inputs and others as outputs. I need to add the NewState value on bits 0-5 of LATC, bits 6 and 7 are input: Update the focus pins: ' Focuses 1-6 (bits 0-5) on LATB.0-5, preserving bits 6-7 (strobe) LATB = (LATB And %11000000) Or (NewState And %00111111) This way, you directly write all the bits you need in a single pass and don't disturb the input bits.