Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

After bootloader works, but through the programmer does not
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
sasha_1973

Bascom Member



Joined: 30 Jul 2013
Posts: 58

ukraine.gif
PostPosted: Wed Mar 18, 2015 4:12 am    Post subject: After bootloader works, but through the programmer does not Reply with quote

Health to you!


There was an inexplicable problem: - after bootloader works, but through the programmer does not want to, please tell me, what could be the reason?

Tested Bascom 2.0.7.1; 2.0.7.8

Programmers - USBISP; USBISP MKII

Previously, these problems were not observed!

(BASCOM-AVR version : 2.0.7.8 )
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 1801

blank.gif
PostPosted: Wed Mar 18, 2015 7:27 am    Post subject: Reply with quote

If the program is flashed via ISP, it overwrites the bootloader, the reset vector still points then to the bootloader section and fails accordingly. You need to change the BOOTRST fuse.
Back to top
View user's profile
sasha_1973

Bascom Member



Joined: 30 Jul 2013
Posts: 58

ukraine.gif
PostPosted: Wed Mar 18, 2015 10:18 am    Post subject: Reply with quote

MWS wrote:
If the program is flashed via ISP, it overwrites the bootloader, the reset vector still points then to the bootloader section and fails accordingly. You need to change the BOOTRST fuse.



Does not work. Fyuz set correctly.
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 1801

blank.gif
PostPosted: Wed Mar 18, 2015 10:50 am    Post subject: Reply with quote

If the BOOTRST fuse is set correctly (unprogrammed=1), then some more possible effects could be:
1) the bootloader prepares anything for the external attached hardware
2) the bootloader sets up some of the internal controller hardware, which the application itself forgets to set up
3) the bootlader creates itself a delay, which allows the attached hardware to get ready
4) the ISP programmer is disconnected from USB, but not from ISP, which may block the used ISP-pins

For 1, I don't see anything in the bootloader doing this, 2 only the UART gets set up, 3 maybe, 4 maybe.

You better describe "does not want to": does it not work at all, or does only some function not work as intended?
And show a screen shot of fuse settings.

Next step: write a small program, which simply toggles a pin, or blinks a led, to test that normal program start works.
Back to top
View user's profile
Evert :-)

Bascom Expert



Joined: 18 Feb 2005
Posts: 2107

netherlands.gif
PostPosted: Wed Mar 18, 2015 9:42 pm    Post subject: Reply with quote

Do you remove the ISP when trying?

Keep in mind that if you use the hardware SPI with the Noss option you need to set the SS pin (B2) to output, think your program stucks on the Config spi, helpfile:
Quote:
In order to use the SPI in master mode, you need to set the SS pin to output. You only need to set the pin to output when you use the NOSS=1 option.

Code:

#if Const_realization_spi = 0
      Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = High , Phase = 0 , Clockrate = 4 , Noss = 1
      Config portb.2 = output
#endif
 

_________________
www.evertdekker.com Bascom code vault
Back to top
View user's profile Visit poster's website
sasha_1973

Bascom Member



Joined: 30 Jul 2013
Posts: 58

ukraine.gif
PostPosted: Thu Mar 19, 2015 3:11 am    Post subject: Reply with quote

Evert Smile wrote:
Do you remove the ISP when trying?

Keep in mind that if you use the hardware SPI with the Noss option you need to set the SS pin (B2) to output, think your program stucks on the Config spi, helpfile:
Quote:
In order to use the SPI in master mode, you need to set the SS pin to output. You only need to set the pin to output when you use the NOSS=1 option.




The note says: --"1 or 0. Use 1 when you do not want the SS signal to be generated in master mode." I have done so and.


Const Const_realization_spi = 0 ' If "0" - implementation of hardware (hardware terminals), if "1" - implementation of software (any conclusions)

#if Const_realization_spi = 0
Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = High , Phase = 0 , Clockrate = 4 , Noss = 1
#endif

#if Const_realization_spi = 1
Config Spi = Soft , Din = Pind.5 , Dout = Portd.6 , Clock = Portd.7 , Ss = None
#endif

Cs_max7219 Alias Portb.0 : Config Cs_max7219 = Output

Spsr.0 = 1 : Spcr.0 = 0 : Spcr.1 = 0 ' F_spi = F_osc / 2; Double Speed (CK/2) Master SPI Mode

Spiinit
Waitms 50


If it would not be right, would not work and after the bootloader


Last edited by sasha_1973 on Thu Mar 19, 2015 3:16 am; edited 1 time in total
Back to top
View user's profile
sasha_1973

Bascom Member



Joined: 30 Jul 2013
Posts: 58

ukraine.gif
PostPosted: Thu Mar 19, 2015 3:21 am    Post subject: Reply with quote

MWS wrote:
Next step: write a small program, which simply toggles a pin, or blinks a led, to test that normal program start works.



It does not work exactly the source! Any other works without problems.
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 1801

blank.gif
PostPosted: Thu Mar 19, 2015 8:46 am    Post subject: Reply with quote

sasha_1973 wrote:
It does not work exactly the source!

Nearly impossible to understand what you write.
Quote:
Any other works without problems.

Does that say, that other code, for example a blink-code, does work, but the attached code in your top-post does not work at all?
Or does it say, that your attached code only works partly?

Did you even try to understand, what Evert wrote?
Evert Smile wrote:
you need to set the SS pin (B2) to output

You do not set the SS-pin to output in your code.
Still it would work, if the SS-pin would be pulled high by an external resistor, but if the circuit lacks also this resistor, the pin is able to float.
Open pins have a very high input impedance and thus they may take random states.
As Atmels datasheet reads:
Quote:
If SS is configured as an input, it must be held high to ensure Master SPI operation. If the SS pin is driven low by peripheral circuitry when the SPI is configured as a Master with the SS pin defined as an input, the SPI system interprets this as another master selecting the SPI as a slave and starting to send data to it. To avoid bus contention, the SPI system takes the following actions: ...

it becomes clear, that if the SS-pin is not output or in a defined state, the whole thing works only randomly.
The reason it works with bootloader but not with ISP, may be looked up in the magic crystal ball, but is otherwise of no further interest, as first you have to correct either your code or your circuit.
So this:
Quote:
If it would not be right, would not work and after the bootloader

may be the wrong conclusion. However, still I can only guess, what you want to say.
Would you mind to use google translator, or a similar service?
Back to top
View user's profile
sasha_1973

Bascom Member



Joined: 30 Jul 2013
Posts: 58

ukraine.gif
PostPosted: Thu Mar 19, 2015 4:29 pm    Post subject: Reply with quote

[/quote]
may be the wrong conclusion. However, still I can only guess, what you want to say.
Would you mind to use google translator, or a similar service?[/quote]

And you think I am than I use?


А Вы думаете, я чем я пользуюсь?
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 1801

blank.gif
PostPosted: Thu Mar 19, 2015 5:02 pm    Post subject: Reply with quote

sasha_1973 wrote:
А Вы думаете, я чем я пользуюсь?

"And you think I'm what I use"

Better would be:
"What do you think, what I use"

Ok, I guess Google has to work on it Very Happy

How about the tech details: did you set the SS-pin to output?
Back to top
View user's profile
sasha_1973

Bascom Member



Joined: 30 Jul 2013
Posts: 58

ukraine.gif
PostPosted: Thu Mar 19, 2015 5:15 pm    Post subject: Reply with quote

Cs_max7219 Alias Portb.0 : Config Cs_max7219 = Output

А это по Вашему, что?

And it is in your opinion, what?
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 1801

blank.gif
PostPosted: Thu Mar 19, 2015 5:23 pm    Post subject: Reply with quote

sasha_1973 wrote:
Cs_max7219 Alias Portb.0 : Config Cs_max7219 = Output
And it is in your opinion, what?

PB0 is the pin you use for CS of the max7219, but we do not talk about that.
We talk about the ATMega328P SS-pin on PB2, this pin needs to be set either to output or pulled high externally, to make the SPI work properly as master.
It does not matter, if you do not use this pin at all, as these are the requirements given by Atmel.
See my excerpt above of the datasheet.
Back to top
View user's profile
sasha_1973

Bascom Member



Joined: 30 Jul 2013
Posts: 58

ukraine.gif
PostPosted: Thu Mar 19, 2015 5:29 pm    Post subject: Reply with quote

Хорошо, тогда почему не работает программный SPI ?

Well, then why do not run the soft SPI ?
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 1801

blank.gif
PostPosted: Thu Mar 19, 2015 5:52 pm    Post subject: Reply with quote

sasha_1973 wrote:
Хорошо, тогда почему не работает программный SPI ?
Well, then why do not run the soft SPI ?


Try this, it gave me a better translation than Google:
http://www.online-translator.com/

For your question: how would I know? We did not talk about that.
Your code uses Const Const_realization_spi = 0, means hard-SPI, and that is what we talked about.
As far I read from the thread, you did not tell whether soft-SPI runs or runs not.

How would it be, if you set the *?&%$? pin as output and report the result?
Back to top
View user's profile
sasha_1973

Bascom Member



Joined: 30 Jul 2013
Posts: 58

ukraine.gif
PostPosted: Thu Mar 19, 2015 6:25 pm    Post subject: Reply with quote

MWS wrote:
Try this, it gave me a better translation than Google:
http://www.online-translator.com/


Спасибо!
Thanks!


По поводу (Const Const_realization_spi = 0 или = 1), не имеет значения, не работают оба варианта!
In an occasion (to Const Const_realization_spi = 0 or = 1), doesn't matter, both options don't work!
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum