Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Atmega328pb - cannot get any LED's to turn on!?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
TSEYFARTH

Bascom Member



Joined: 01 Jul 2006
Posts: 1054

usa.gif
PostPosted: Wed Jan 06, 2021 11:36 pm    Post subject: Atmega328pb - cannot get any LED's to turn on!? Reply with quote

Hello all.

I have a simple program and all I want to do is to turn on a couple of LED's using the Atmega328PB. Even when I use the sample program and add the code they still wont turn on.


Code:

$regfile = "m328pbdef.dat"
$crystal = 16000000
$baud = 19200
$hwstack = 40
$swstack = 40
$framesize = 40

'Config Clockdiv = 1                                         'make sure we get 8 Mhz from internal osc
  'For LED Indicators ***********************
   Snddataled Alias Portd.6
   Config Snddataled = Output                               'Input
   Set Snddataled                                           'Set = High

   Recdataled Alias Portd.5
   Config Recdataled = Output                               'Input
   Set Recdataled                                           'Set = High

   BT_Snddataled Alias Portc.1
   Config BT_Snddataled = Output                               'Input
   Set BT_Snddataled                                           'Set = High

   BT_Recdataled Alias Portc.0
   Config BT_Recdataled = Output                               'Input
   Set BT_Recdataled                                           'Set = High



   Reset Snddataled
   Reset Recdataled
   Reset bt_snddataled
   Reset bt_recdataled
'   Waitms 1000
'   Set Recdataled
'   Set Snddataled
'   set bt_snddataled
'   set bt_recdataled




Print "Scan start"
[img]
Do
   Print "COM1"
   Waitms 1000
Loop

 



A schematic is included here to see too...

Thanks in advance!
Tim



(BASCOM-AVR version : 2.0.8.3 )
Back to top
View user's profile
TSEYFARTH

Bascom Member



Joined: 01 Jul 2006
Posts: 1054

usa.gif
PostPosted: Thu Jan 07, 2021 2:39 am    Post subject: Reply with quote

I've also tried with an ATMEGA88 - which is pin compatible, at least for the pins I am using!

Still no good.

If I bypass the uC and bring ground to the LED, it does turn on, but will not turn on with the uC.

Any help/ideas would be appreciated!
Thank you,
Tim
Back to top
View user's profile
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 248
Location: D.F.

mexico.gif
PostPosted: Thu Jan 07, 2021 3:16 am    Post subject: Reply with quote

Positive anode and negative cathode turn on led and positive anode and positive cathode off led.

Code:
Snddataled Alias Portd.6
   Config Snddataled = Output                               'Output
   Reset Snddataled                                           'Reset = High ;Led ON

   Recdataled Alias Portd.5
   Config Recdataled = Output                               'Output
   Reset Recdataled                                           'Reset = High; Led ON

   BT_Snddataled Alias Portc.1
   Config BT_Snddataled = Output                               'Output
   Reset BT_Snddataled                                           'Reset = High;Led ON

   BT_Recdataled Alias Portc.0
   Config BT_Recdataled = Output                               'Output
   Reset BT_Recdataled                                           'Reset = High;Led ON



   set Snddataled                                                 'Led OFF
   set Recdataled                                                 'Led OFF
   set bt_snddataled                                             'Led OFF
   set bt_recdataled 'Led OFF


Very Happy Very Happy
Back to top
View user's profile
enniom

Bascom Member



Joined: 20 Oct 2009
Posts: 496

PostPosted: Thu Jan 07, 2021 3:22 am    Post subject: Reply with quote

Code:


 Config BT_Snddataled = Output                               'Input
 


Input?

LED powered from 3v3?



E

[PS: is it COM1 or COM0? ]
Back to top
View user's profile
EDC

Bascom Expert



Joined: 26 Mar 2014
Posts: 733

poland.gif
PostPosted: Thu Jan 07, 2021 9:32 am    Post subject: Reply with quote

Why not to ground pin 21 on the schematic? Very Happy
Your code copied from this forum is working -> see pics.





Last edited by EDC on Thu Jan 07, 2021 10:08 am; edited 1 time in total
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5235
Location: Holland

blank.gif
PostPosted: Thu Jan 07, 2021 9:36 am    Post subject: Reply with quote

avcc seems unconnected.

when searching for problems :
- check short circuit between gnd and vcc but since the firmware programs that should be no problem
- check short circuit on the output pin
- check voltage. simple way is to to use 2 led with one led reverse connected. and of course with a series resistor

then it is important that the good way to connect is as you did between vcc and the port : making a port pin low will make the led light
of course new avr also allow to connect between the port pin and gnd : making a port pin high will make the led light

the total mA a port/processor can draw you can find in the datasheet.

since that is all ok i assume that avcc is the problem.
you can also do the simple test :

Code:
config portd.5=output
do
  toggle portd.5
  waitms 1000
loop

_________________
Mark
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5235
Location: Holland

blank.gif
PostPosted: Thu Jan 07, 2021 9:38 am    Post subject: Reply with quote

EDC wrote:
Why not to ground pin 21 on the schematic? Very Happy

haha, yes that is essential.
basically ; when the simple led program does not work : check your hardware

_________________
Mark
Back to top
View user's profile Visit poster's website
SZTRAD

Bascom Member



Joined: 30 Dec 2019
Posts: 121

blank.gif
PostPosted: Thu Jan 07, 2021 11:20 am    Post subject: Reply with quote

Unfortunately I don't have AT328PB connected here, but all other atmegs have internally connected GND.
I'm not saying they shouldn't get involved.
A fellow interviewer did not write if the transfer to COM works for him. If not, his chip isn't working. If so, RESET is active (externally or internally).


Last edited by SZTRAD on Thu Jan 07, 2021 1:02 pm; edited 1 time in total
Back to top
View user's profile
hgrueneis

Bascom Member



Joined: 04 Apr 2009
Posts: 885
Location: A-4786 Brunnenthal

austria.gif
PostPosted: Thu Jan 07, 2021 12:51 pm    Post subject: Reply with quote

A 10K pullup on the RESET might also be helpful.
Regards
Hubert
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 1934

blank.gif
PostPosted: Thu Jan 07, 2021 5:34 pm    Post subject: Reply with quote

And don't use blue or white Leds with a VCC of 3.3V ;D
Back to top
View user's profile
hgrueneis

Bascom Member



Joined: 04 Apr 2009
Posts: 885
Location: A-4786 Brunnenthal

austria.gif
PostPosted: Thu Jan 07, 2021 7:19 pm    Post subject: Reply with quote

If you doubt all the help , that very experienced people give you here, then you should go somewhere else.
You do not even attend to the bare essentials of the electronic requirement for these processors.
My advice, study the datasheets and the Bascom Help. When you are through with that and you still have problems, come back here.
Otherwise "Good luck"

Regards
Hubert
Back to top
View user's profile
TSEYFARTH

Bascom Member



Joined: 01 Jul 2006
Posts: 1054

usa.gif
PostPosted: Thu Jan 07, 2021 9:18 pm    Post subject: Reply with quote

Hello all and THANK YOU for all of your helpful responses!

I'm trying the suggestions and will get back with you all.

Thank you again,
Tim
Back to top
View user's profile
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 988
Location: France

france.gif
PostPosted: Fri Jan 08, 2021 11:34 am    Post subject: Reply with quote

a scope is a a good friend Wink
jp

_________________
pleasure to learn, to teach, to create
Back to top
View user's profile Visit poster's website
TSEYFARTH

Bascom Member



Joined: 01 Jul 2006
Posts: 1054

usa.gif
PostPosted: Fri Jan 08, 2021 10:06 pm    Post subject: Reply with quote

Checked with a scope and meter. The pins at the uC stay at 1.7 Volts. They never go to a true hi (3.3) or low.

Other than what has been suggested already, anything else to look at?

Thanks all!
Tim
Back to top
View user's profile
TSEYFARTH

Bascom Member



Joined: 01 Jul 2006
Posts: 1054

usa.gif
PostPosted: Fri Jan 08, 2021 10:15 pm    Post subject: Reply with quote

Also tried toggling a spare set of pins that are not connected to anything. According to the scope, they stayed low and never changed.

Must be something with the PCB or chip? It programs fine so the xtal should be OK, all of the power and grounds are set up now.It is getting 3.3V.

I've never had a situation where the chip did not respond properly.

Any ideas?
Tim

Code:

$regfile = "m328pbdef.dat"
$crystal = 16000000
$baud = 19200
$hwstack = 40
$swstack = 40
$framesize = 40


config portd.5=output
config portd.3=output
config portd.4=output
do
  toggle portd.3
  toggle portd.4
  toggle portd.5
  waitms 1000
loop
 
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  Next
Page 1 of 2

 
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