• AVR Freaks

Hot!Calibrate Oscilloscope

Page: < 12 Showing page 2 of 2
Author
Speedi
New Member
  • Total Posts : 20
  • Reward points : 0
  • Status: offline
Re: Calibrate Oscilloscope 2019/11/05 04:24:26 (permalink)
0
1and0
 
No, it is incomprehensible, but since you all have told me certain things now, I thought in bed last night that it might be the frequency gain which I will be looking at later today. Can't see what else it should be, will not assume that there is error in MPLAB's update which causes it, and has not changed my code, but has made frequency changes, switched the crystal from 4Mhz to 16Mhz, and the only thing I haven't testet is the gain.
 
Otherwise, I'll try with blank startup while considering second and better PIC :)
#21
Mysil
Super Member
  • Total Posts : 3671
  • Reward points : 0
  • Joined: 2012/07/01 04:19:50
  • Location: Norway
  • Status: offline
Re: Calibrate Oscilloscope 2019/11/05 06:21:48 (permalink)
+1 (1)
Hi,
You did say in message #14 that you now have PIC16F1713-I/SP and PIC18F23K20-I/SP.
You may use either of these devices in a solderless breadboard with 2.54 mm spacing.
 
Both devices have the same Master mode I2C peripheral.
Example code and comments in message #16 were intended for these devices.
Registers may be named SSPCON1 or SSP1CON1  depending on device type,
device hardware support file that is included with #include <xc.h> have definition of those symbols.
For some families, both definitions are available.
 
C compiler will understand binary constants, decimal constants and hexadecimal constants,
so 0b1000, 0x8 and 8 (decimal integer) are all the same.
    0b1011 , 0xB or 11 are also the same when translated by the compiler. I2C Firmware Controlled Master mode (slave IDLE), is also available in PIC18F23K20 and PIC16F1713,
and means that your program must bitbang the signals for Master mode transfer.
 
    Mysil
 
#22
davea
Super Member
  • Total Posts : 249
  • Reward points : 0
  • Joined: 2016/01/28 13:12:13
  • Location: Tampa Bay FL USA
  • Status: offline
Re: Calibrate Oscilloscope 2019/11/05 08:06:57 (permalink)
+1 (1)
CLOCK STRETCHING
When a slave device has not completed processing
data, it can delay the transfer of more data through the
process of clock stretching. An addressed slave device
may hold the SCL clock line low after receiving or sending
a bit, indicating that it is not yet ready to continue.
The master that is communicating with the slave will
attempt to raise the SCL line in order to transfer the
next bit, but will detect that the clock line has not yet
been released. Because the SCL connection is
open-drain, the slave has the ability to hold that line low
until it is ready to continue communicating.
Clock stretching allows receivers that cannot keep up
with a transmitter
#23
Speedi
New Member
  • Total Posts : 20
  • Reward points : 0
  • Status: offline
Re: Calibrate Oscilloscope 2019/11/05 08:15:46 (permalink)
0
Mysil
 
PIC16F1713-I / SP was an LF but just got a look and I also have a PIC16F1713-I / SP. So the choice stands between the two for now :)
 
For something like this, I make my own print but use the socket for ic. Takes a little longer, but more stable and better to deal with.
 
Will spend the evening to see which one I take, think it will be 1617 (y)
#24
Speedi
New Member
  • Total Posts : 20
  • Reward points : 0
  • Status: offline
Re: Calibrate Oscilloscope 2019/11/05 08:18:26 (permalink)
0
devea
 
And that is why I assumed it should also be activated so that the master could register this, but understood (y)
 
#25
Speedi
New Member
  • Total Posts : 20
  • Reward points : 0
  • Status: offline
Re: Calibrate Oscilloscope 2019/11/05 08:24:35 (permalink)
0
Looked at the frequency gain which was only 1.42V and the datasheet writes about 4-5.5V but no change with more gain, and also examined if a frequency could be read on a port set as "TRISBbits.TRISB5 = ~ TRISBbits.TRISB5;" and the measuring was around 11MHz so it fluctuates even at 1.42V :-/
 
The code then :(
#26
Speedi
New Member
  • Total Posts : 20
  • Reward points : 0
  • Status: offline
Re: Calibrate Oscilloscope 2019/12/14 07:00:47 (permalink)
0
Just an update.
 
Although it is good to be able to use MCC, it uses a lot of memory and not all modules are easily understandable in the use of code, which is probably a lack of experience, although I do not really find good descriptions of the modules that MCC loads in the various files.
 
In my trial with 73, coded with i2c as master, full PCF8577 commutation as well some code lines, until the error appeared, I used 67% Data and about 72% Program.
 
Where 1713, MSSP (master/simple), TMR1 and 4, PWM3, CCP2, ADC (1), EEPROM and 5 switches. And not much of my own code, and yet Program memory is filled up 100% :(
 
I have therefore ordered a 1718 which I hope is enough, can always order one best suited when I know how much memory there will be used.
 
However, have a question about MSSP. Have tried setting up MSSP without using (master/simple) and EEPROM module, and also able to send data out after the Start signal, also got ACK back, but after that, it is actually no matter what I try, I can not get BUF to send further data. Seems I've tried everything, reading and waiting for BF, SSPIF, but nothing. Can only send a Start and write BUF once, then I can not move on. What do I overlook?
#27
ric
Super Member
  • Total Posts : 27704
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Calibrate Oscilloscope 2019/12/14 14:20:29 (permalink)
+2 (2)
Speedi
 What do I overlook?

Impossible to answer without seeing the actual code you used.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#28
Speedi
New Member
  • Total Posts : 20
  • Reward points : 0
  • Status: offline
Re: Calibrate Oscilloscope 2019/12/14 17:30:06 (permalink)
0
minimum resolution to send, and send start, and write once from buf, so I can do nothing more. Not really written a direct code, only minium setup for 100khz did not assume that it required code to give an idea. tomorrow
#29
Speedi
New Member
  • Total Posts : 20
  • Reward points : 0
  • Status: offline
Re: Calibrate Oscilloscope 2019/12/15 08:51:05 (permalink)
0
SSP1STAT = 0x00;
SSP1CON1 = 0x28; //master mode
SSP1CON2 = 0x00;
SSP1ADD = 0x31; //100Khz

SSP1CON2bits.SEN = 1; //start
while (SSP1CON2bits.SEN==1){} //wait until done
SSP1BUF = 0xA0;
if (PIR1bits.SSP1IF==1){PIR1bits.SSP1IF = 0;} //interrupt cleard if - only as security in trials
while (SSP1STATbits.BF==1){} //wait until buffer empty
while (SSP1CON2bits.ACKSTAT==1){} //wait until ack received
if (PIR1bits.SSP1IF==1){PIR1bits.SSP1IF = 0;} //interrupt cleard if - only as security in trials
SSP1BUF = 0xAA;
 
Transmits Start, Data and get ACK, but then nothing more happens, no matter what I do, almost. SDA stands high and SCL low.
 
But if I set a delay before 0xAA of 100us, then the buffer also sends out data. Shouldn't that work without delay? 
 
Do not use MSSP in MCC
post edited by Speedi - 2019/12/15 08:53:20
#30
ric
Super Member
  • Total Posts : 27704
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Calibrate Oscilloscope 2019/12/15 12:18:30 (permalink)
+2 (2)
This bit of code is wrong
while (SSP1STATbits.BF==1){} //wait until buffer empty
while (SSP1CON2bits.ACKSTAT==1){} //wait until ack received

Do NOT wait for the ACKSTAT bit.
Wait for the complete transfer to finish. This is indicated by either the R/W bit, or the SSPIF flag (so long as you cleared it before writing to SSPBUF)
Then, read the ACKSTAT bit once.
If it is low, you got an ACK. If it is high, you got a NAK, and no matter how long you wait, it will not change from a NAK to an ACK.
 
If you get an ACK, the slave received the address ok, and you can proceed.
If you get a NAK, this could indicate many possible problems.
i.e. The address is wrong.
SDA and/or SCL is not connected to the Slave correctly.
 
If this happens, there's no point proceeding or retrying. You have a problem that needs to be fixed.

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#31
Speedi
New Member
  • Total Posts : 20
  • Reward points : 0
  • Status: offline
Re: Calibrate Oscilloscope 2019/12/15 12:52:36 (permalink)
0
This is just a test to see what it takes to get data sent out the second time. (SSP1CON2bits.ACKSTAT == 1) {} is inserted to wait for the bit to be cleaned after ACK is received. (the bus runs 100khz, pic runs 20mhz)
 
And neither RW nor PIF has an effect, have tried.
 
post edited by Speedi - 2019/12/15 13:02:15

Attached Image(s)

#32
Speedi
New Member
  • Total Posts : 20
  • Reward points : 0
  • Status: offline
Re: Calibrate Oscilloscope 2019/12/15 13:15:20 (permalink)
0
SSP1CON2bits.SEN = 1;
while (SSP1CON2bits.SEN==1){}
PIR1bits.SSP1IF = 0;
SSP1BUF = 0xA0;
while (SSP1STATbits.R_nW==1){}
PIR1bits.SSP1IF = 0;
SSP1BUF = 0xAA;
 
It helped, thank you very much :)
#33
ric
Super Member
  • Total Posts : 27704
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Calibrate Oscilloscope 2019/12/15 14:07:44 (permalink)
+1 (1)
Speedi
This is just a test to see what it takes to get data sent out the second time. (SSP1CON2bits.ACKSTAT == 1) {} is inserted to wait for the bit to be cleaned after ACK is received. (the bus runs 100khz, pic runs 20mhz)

This is just plain wrong, and demonstrates a misunderstanding of what the ACK bit is and how it works.
 

And neither RW nor PIF has an effect, have tried.

I see from your following post that when you tried it correctly, it DID work.
However, your real code must check the ACKSTAT bit once after sending the address. If you don't get an ACK, then there's no-one listening to you.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#34
Speedi
New Member
  • Total Posts : 20
  • Reward points : 0
  • Status: offline
Re: Calibrate Oscilloscope 2019/12/15 14:28:34 (permalink)
0
As written, only quick tests, now I want to step away from using MCC's MSSP, so just sat and tried various little quick setups that just didn't work. Just not exactly in that order :)
 
But yes, it doesn't take much to misunderstand, too many codes in the head, disruptions in private life or just how the datasheet is sometimes formulated as.
 
Now that I know that small fast code can be done, rather than F73 as I knew, I can make small routines to suit my needs. ACK will make a check, although not really needed for what I'm going to use it for, only cases where there will be no ACK, defective chip or maybe some interruptions on the line, otherwise there should be no need to examine it. The same is the case with for example WCOL, there will never be a chance for that to happen.
 
Also curious to see how much memory I will save :) i hope...
#35
Speedi
New Member
  • Total Posts : 20
  • Reward points : 0
  • Status: offline
Re: Calibrate Oscilloscope 2019/12/18 10:11:18 (permalink)
0
It gave alot more memory space, 15% data and 48% program :)
#36
Page: < 12 Showing page 2 of 2
Jump to:
© 2020 APG vNext Commercial Version 4.5