UNO SCADA SPI Prescaler question

For general Flowcode discussion that does not belong in the other sections.
User avatar
p.erasmus
Posts: 434
http://meble-kuchenne.info.pl
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

UNO SCADA SPI Prescaler question

Post by p.erasmus »

Hi Team.

From the UNO SCADA help file the values for the SPI prescaler range from 0 -2 (0,1,2)
Can you guys please help me if the UNO Clock frequency is 16MHZ what will the SPI Clock then be if we use
0, = ?
1, = ?
2, = ?
prescaler
:(
P1.jpg
P1.jpg (28.19 KiB) Viewed 4538 times
Thanks for helping out
:D
Regards Peter - QME Electronics

mnfisher
Valued Contributor
Posts: 991
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 106 times
Been thanked: 517 times

Re: UNO SCADA SPI Prescaler question

Post by mnfisher »

The documents aren't very clear?

I'd guess the values correspond to prescaler of 4, 16, and 64 (ie clock of 16Mhz (FOsc?) / prescale) - the firmware calls SetPrescaler in the CAL SPI. (Docs don't specify here either)

Edit - however experimenting in v8 (see below) - calling SetPrescaler with (2,4,8 etc) gives the expected results (at least in software mode).

Some problems:

I tested on a Nano - and the default CS pin for hardware mode is incorrectly set to C2 (instead of B2) -
Hardware mode didn't work on a very basic program..

Master_init
Loop
Master_Byte(123)
end loop

Tested using v8 (so I can upload) - and this works in software mode only (I just look at the CLK on D13 on the oscilloscope)

In V9:
After upgrading the Nano def file - uploading fails

H:\>"H:\AVR\avrv5\batchfiles\..\bin\avrdude.exe" -p m328p -P 57600 -b "H:\spi test.hex" -c arduino -D -U flash:w:""
avrdude.exe: invalid baud rate specified 'H:\spi test.hex'

- The command line argument for avrdude is now messed up (should be -b (baud rate) 57600 - NOT -P 57600 -b file...)

Martin

User avatar
p.erasmus
Posts: 434
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Re: UNO SCADA SPI Prescaler question

Post by p.erasmus »

Martin,

Thanks for the info,

However this Baud problem isn't it part of my problem on the Chinese UNO( as I mentioned the supplier settings mention 57600 ,I cannot judge this never worked with AVR and its tools, component simulation forced me to use the UNO for many reasons,

viewtopic.php?f=3&t=203

Example if I use the ARDUINO IDE I can connect to the Chinese UNO and program it ,from V9 it is not possible to program from V9 ,but then again confusing me ,a Genuine Arduino UNO I have no problems with programming from V9 and use in HW SCADA simulation however this was with I2C ,will see now with SPI :D :D
Regards Peter - QME Electronics

mnfisher
Valued Contributor
Posts: 991
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 106 times
Been thanked: 517 times

Re: UNO SCADA SPI Prescaler question

Post by mnfisher »

Hi Peter,

Have you tried loading the newer bootloader onto the clone Uno?

See https://www.instructables.com/How-to-Up ... 0to%20Nano

For example?

Martin

User avatar
p.erasmus
Posts: 434
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Re: UNO SCADA SPI Prescaler question

Post by p.erasmus »

Martin.

I still did not do that because of time and afraid to mess around with my new UNO ,costing a fortune if you pay with my country's exchange rate :o

I will probably try it once I have done what I want with the SCADA Simulation as I have to make one UNO to a Programmer by loading new SW on it and then program the other one a risky thing for a PIC user on a AVR :D

Thanks for the link will do that asap
Regards Peter - QME Electronics

mnfisher
Valued Contributor
Posts: 991
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 106 times
Been thanked: 517 times

Re: UNO SCADA SPI Prescaler question

Post by mnfisher »

I just re-flashed a clone Nano - using a USB Tiny.. Much nicer working at 115200 :)

But - no the baud rate shouldn't affect the SPI (and see new edit above about the 0,1,2)

I've added a bug report about that...

Something not quite right with the SPI on the AVR chips. I've put bug reports about the USI implementation (in the old forum) - but have had problems with the hardware implementation on Arduino before :-( Maybe I do something wrong??

Martin

User avatar
p.erasmus
Posts: 434
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Re: UNO SCADA SPI Prescaler question

Post by p.erasmus »

Thanks for all the help Martin,
If things improve in future I will order a ECIO28P as I like to work with PIC's and the reason is I understand their inner workings and have no idea of ATMEL so easier for me to carry on with PIC :D ,It is so easy to work with the SCADA Simulation in testing and developing interfaces
Regards Peter - QME Electronics

mnfisher
Valued Contributor
Posts: 991
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 106 times
Been thanked: 517 times

Re: UNO SCADA SPI Prescaler question

Post by mnfisher »

Thanks for giving us a pointer on this - it was interesting, I've not really used SCADA, to see how useful it can be!

Will have to have a more in depth play when time allows...

Martin

User avatar
p.erasmus
Posts: 434
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Re: UNO SCADA SPI Prescaler question

Post by p.erasmus »

mnfisher wrote:
Sat Feb 20, 2021 7:38 pm
Something not quite right with the SPI on the AVR chips. I've put bug reports about the USI implementation (in the old forum) - but have had problems with the hardware implementation on Arduino before :-( Maybe I do something wrong??
Hi Martin ,
I am running SPI on the UNO Scada ,I see no issue with the SPI it is working fine for me at least at the moment
P2.jpg
P2.jpg (24.21 KiB) Viewed 4419 times
:D :D
Regards Peter - QME Electronics

mnfisher
Valued Contributor
Posts: 991
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 106 times
Been thanked: 517 times

Re: UNO SCADA SPI Prescaler question

Post by mnfisher »

Hi Peter,

The problem - the hardware mode on USI gives no signal. (Implementation uses MOSI (which label refers to connection for programmer such as USBTiny) - but needs to use DOUT which on ATTiny 85 is d1 and not d0.

I've occasionally hit a problem where there is no signal on MOSI on Arduino - and nothing works until the program 'hits' a certain size. Or something changes - I've never managed to quite pin down what the problem is - but like the example in previous message - software mode works AOK but no signal on hardware mode..

What effect did you get with the prescaler values??

Martin

Post Reply