Reply by rickman October 22, 20152015-10-22
On 10/19/2015 2:44 PM, srao wrote:
>> On 10/17/2015 7:42 AM, Simon Clubley wrote: >>> On 2015-10-17, rickman <gnuarm@gmail.com> wrote: >>>> On 10/16/2015 7:33 PM, srao wrote: >>>>>> Did something like this:- >>>>>> >>>>>> while(1) >>>>>> { >>>>>> >>>>>> for (N loops) //togggle watchdog >>>>>> { >>>>>> //port1 clear bits >>>>>> Set bit on watchdog PIN >>>>>> outport(0x00xx,a); >>>>>> } >>>>>> >>>>>> for (N loops) >>>>>> { >>>>>> //port1 clear bits >>>>>> //Clear bit on watchdog PIN >>>>>> outport(0x00xx,a); >>>>>> } >>>>>> --------------------------------------- >>>>> not sure if I am doing something wrong here. the above code does not >>>>> toggle the Port pin. is there a better way to solve this? >>>> >>>> Where do you change the value written to the port? You don't even > show >>>> where you set the value of 'a' initially. >>>> >>> >>> The OP _really_ needs to show us _actual_ code not the above pseudo > code. >>> >>> Also, the above sequence "feels" really wrong to me. Why is the port >>> pin being set N times and then cleared N times ? >>> >>> With a watchdog you are supposed to send a specific sequence _once_ >>> every time you decide to report that you are still alive and not > stuck. >> >> I'm guessing this is test code to get the durn thing to work without >> resetting. I get that. But he needs to show his code. >> >> -- >> >> Rick > > Hi Rick, > > I will post the complete code soon. As far as i read the data sheet, the > watchdog (hardware) is connected to one of the ooutput pins and I am just > trying to continously write 0 or 1 to this port to not allow it to kick > the watchdog timer and reset the pin. I did not find a mention of a > specific sequence to be set to stop the watchdog from kicking. Will post > source code soon.
I can't say I understand much of this. Usually the watchdog is not active until activated somehow. Then you write alternating 1 and 0 to the pin to swing it which resets the watchdog timer so it does *not* reset the CPU. Also, all the CPU watchdogs I have seen are just mapped to I/O addresses that control it, not external pins. Is this watchdog a separate chip? Is this not what you are picturing or do *I* not understand how your watchdog works? -- Rick
Reply by srao October 21, 20152015-10-21
>On 21.10.15 01:37, Stef wrote: > >--- clip clip --- > >> I do know some PICs (ouch, long time ago), but have never heard of
IAR's.
>> >> How do you expect to clear a bit in the registers with the above code? >> Why do you need to repeat this 2000 times? >> If you wanted to do this on a PIC, how would you do it? >> >> IIRC on a PIC you always had to load stuff into the W register before >> you could do anything... > > >The OP seems to mix up processors and compilers. IAR is a Swedish >companu producing compilers. Their compiler was once upon time the >most popular for 8051's. > >-- > >-TV
Hello all. I got the UART working. Thanks for your help. Seems like the watchdog reset was not allowing the UART to function correctly. Thanks all for all the suggestions and comments. --------------------------------------- Posted through http://www.EmbeddedRelated.com
Reply by David Brown October 21, 20152015-10-21
On 21/10/15 08:15, Tauno Voipio wrote:
> On 21.10.15 01:37, Stef wrote: > > --- clip clip --- > >> I do know some PICs (ouch, long time ago), but have never heard of IAR's. >> >> How do you expect to clear a bit in the registers with the above code? >> Why do you need to repeat this 2000 times? >> If you wanted to do this on a PIC, how would you do it? >> >> IIRC on a PIC you always had to load stuff into the W register before >> you could do anything... > > > The OP seems to mix up processors and compilers. IAR is a Swedish > companu producing compilers. Their compiler was once upon time the > most popular for 8051's. >
I didn't know that IAR was ever the most popular choice for 8051's - I thought that was always Keil, with IAR being the alternative option (and SDCC for those that prefer open source tools). So that's an interesting bit of history. One of the key strengths of IAR is that they have compilers for a range of small micros, so the are popular for companies looking for consistency over several different small devices. They also work closely with manufacturers, and have often been the first or only choice at the beginning - such as for Atmel AVR or TI MSP430. AFAIK, IAR never made a PIC compiler.
Reply by Tauno Voipio October 21, 20152015-10-21
On 21.10.15 01:37, Stef wrote:

--- clip clip ---

> I do know some PICs (ouch, long time ago), but have never heard of IAR's. > > How do you expect to clear a bit in the registers with the above code? > Why do you need to repeat this 2000 times? > If you wanted to do this on a PIC, how would you do it? > > IIRC on a PIC you always had to load stuff into the W register before > you could do anything...
The OP seems to mix up processors and compilers. IAR is a Swedish companu producing compilers. Their compiler was once upon time the most popular for 8051's. -- -TV
Reply by srao October 20, 20152015-10-20
>On 2015-10-20 Stef wrote in comp.arch.embedded: > >> As Rick already said, > >Sorry, not Rick but David. > >Stupid missing attributions from embeddedrelated. > >-- >Stef (remove caps, dashes and .invalid from e-mail address to reply
by
>mail) > >And then there was the lawyer that stepped in cow manure and thought >he was melting...
TO EVERYONE WHO DIDN'T UNDERSTAND THE QUESTION: I am sorry its difficult for you to get the thing. I guess we dont share the same language. I don't find any point responding back to your comments. TO EVERYONE WHO HELPED(understood the question): Thank you so much for your inputs. With your help I was able to get to the first step.. The watchdog. I think now i can get the UART working too. Thanks a ton. --------------------------------------- Posted through http://www.EmbeddedRelated.com
Reply by Stef October 20, 20152015-10-20
On 2015-10-20 Stef wrote in comp.arch.embedded:

> As Rick already said,
Sorry, not Rick but David. Stupid missing attributions from embeddedrelated. -- Stef (remove caps, dashes and .invalid from e-mail address to reply by mail) And then there was the lawyer that stepped in cow manure and thought he was melting...
Reply by Stef October 20, 20152015-10-20
On 2015-10-20 srao wrote in comp.arch.embedded:
>>On 20/10/15 00:22, srao wrote: >>>> On 2015-10-17, rickman <gnuarm@gmail.com> wrote: >>>>> On 10/16/2015 7:33 PM, srao wrote: >>>>>>> Did something like this:- >>>>>>> >>>>>>> while(1) >>>>>>> { >>>>>>> >>>>>>> for (N loops) //togggle watchdog >>>>>>> { >>>>>>> //port1 clear bits >>>>>>> Set bit on watchdog PIN >>>>>>> outport(0x00xx,a); >>>>>>> } >>>>>>> >>>>>>> for (N loops) >>>>>>> { >>>>>>> //port1 clear bits >>>>>>> //Clear bit on watchdog PIN >>>>>>> outport(0x00xx,a); >>>>>>> } >>>>>>> --------------------------------------- >>>>>> not sure if I am doing something wrong here. the above code does > not >>>>>> toggle the Port pin. is there a better way to solve this? >>>>> >>>>> Where do you change the value written to the port? You don't even > show >>> >>>>> where you set the value of 'a' initially. >>>>> >>>> >>>> The OP _really_ needs to show us _actual_ code not the above pseudo >>> code. >>>> >>>> Also, the above sequence "feels" really wrong to me. Why is the port >>>> pin being set N times and then cleared N times ? >>>> >>>> With a watchdog you are supposed to send a specific sequence _once_ >>>> every time you decide to report that you are still alive and not > stuck. >>>> >>>> Simon. >>>> Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP >>>> Microsoft: Bringing you 1980s technology to a 21st century world >>> >>> >>> >>> The exact source code is as below. This lies within main() >>> >>> >>> while(1) >>> { >>> >>> for (i=0;i<2000;i++) >>> { >>> int p1dir=inport(0x0050); //clear PD5 bit PXDIR register >>> p1dir &= ~(1 << 5); >>> >>> int p1con=inport(0x0054); //clear PC5 bit in PXCON register >>> p1con &= ~(1 << 5); >>> >>> int b=0x20; //toggle watchdog >>> int a=inport(0x0056); >>> a&=~b; >>> outport(0x0056,a); >>> } >>> >>> for (i=0;i<2000;i++) >>> { >>> int p1dir=inport(0x0050); //clear PD5 bit PXDIR register >>> p1dir &= ~(1 << 5); >>> >>> int p1con=inport(0x0054); //clear PC5 bit in PXCON register >>> p1con &= ~(1 << 5); >>> >>> >>> int b=0x20; >>> int a=inport(0x0056); >>> a|=~b; >>> outport(0x0056,a); >>> } >>> >> >>I'm having difficulty trying to figure out what you are trying to do, >>but I can tell you that no matter what you /think/ you are doing, your >>code is /badly/ wrong. It is wrong in a way that indicates you have no >>idea what you are doing. (This is constructive criticism aimed at >>helping you where you need it most - I am not trying to be insulting.) >> >>It is time to take a step back, and look at the big picture here. What >>are you trying to achieve, and why are you doing it? >> >>If you are trying to learn about embedded programming, you are going >>about it the wrong way - pick a modern, friendly microcontroller and a >>decent book (ask here for advice if you like). >> >>If you are doing this professionally, then it can only be in the context >>of maintaining an ancient system. Without a larger context, it is >>impossible to judge whether something this old /should/ be maintained, >>or whether it would be better to replace it. But it is clear that you >>are not qualified for the job - the sooner you accept that and arrange >>for a qualified person to handle it, the better for everyone (especially >>you). >> >> >>If there is no other possibility than for /you/ to do the programming >>here, then at least hire a consultant for a few days to work with you >>and show you some of the basics. If you have a strong enough background >>in programming or electronics, that might be enough to give you a > chance. > > I know sometimes its hard to understand a question. Everyone has the right > to learn on their own and I am doing my part. > > These are two simple basic programs for UART configuration and watchdog > kick. I was new with this kind of processor as its an old one and never > had to deal with a watchdog scenario, I just posted my questions as I was > unfamiliar with the environment and as I had only worked with PICS and > IAR's. Sorry for the trouble you had.
As Rick already said, it is unclear what you are trying to achieve with the above code. The code shows a lack of knowledge on C programming and on basic processor operating principles. This is OK if you are just learning, but if this is a job... So please tell us what context this is in. I do know some PICs (ouch, long time ago), but have never heard of IAR's. How do you expect to clear a bit in the registers with the above code? Why do you need to repeat this 2000 times? If you wanted to do this on a PIC, how would you do it? IIRC on a PIC you always had to load stuff into the W register before you could do anything... -- Stef (remove caps, dashes and .invalid from e-mail address to reply by mail) Young men, hear an old man to whom old men hearkened when he was young. -- Augustus Caesar
Reply by David Brown October 20, 20152015-10-20
On 20/10/15 18:25, srao wrote:
>> On 20/10/15 00:22, srao wrote:
>> I'm having difficulty trying to figure out what you are trying to do, >> but I can tell you that no matter what you /think/ you are doing, your >> code is /badly/ wrong. It is wrong in a way that indicates you have no >> idea what you are doing. (This is constructive criticism aimed at >> helping you where you need it most - I am not trying to be insulting.) >> >> It is time to take a step back, and look at the big picture here. What >> are you trying to achieve, and why are you doing it? >> >> If you are trying to learn about embedded programming, you are going >> about it the wrong way - pick a modern, friendly microcontroller and a >> decent book (ask here for advice if you like). >> >> If you are doing this professionally, then it can only be in the context >> of maintaining an ancient system. Without a larger context, it is >> impossible to judge whether something this old /should/ be maintained, >> or whether it would be better to replace it. But it is clear that you >> are not qualified for the job - the sooner you accept that and arrange >> for a qualified person to handle it, the better for everyone (especially >> you). >> >> >> If there is no other possibility than for /you/ to do the programming >> here, then at least hire a consultant for a few days to work with you >> and show you some of the basics. If you have a strong enough background >> in programming or electronics, that might be enough to give you a > chance. > > I know sometimes its hard to understand a question. Everyone has the right > to learn on their own and I am doing my part. > > These are two simple basic programs for UART configuration and watchdog > kick. I was new with this kind of processor as its an old one and never > had to deal with a watchdog scenario, I just posted my questions as I was > unfamiliar with the environment and as I had only worked with PICS and > IAR's. Sorry for the trouble you had.
Could you please tell us if you are doing this as a job, or as a hobby? And if it is a job, what is the scope, and why are you doing it? From your posts so far, you are going to need guiding and help with a great deal of work because you don't understand what you are doing - your problems are much bigger than UART configuration or watchdogs. If we know what you are trying to achieve here, we can give better advice. That advice might be in showing you how to clear a bit in a port - but it might also be advice on a book to read, suggestions for replacing the microcontroller and toolchain, or simply to hire an experienced developer for the job. Clearly the advice will be very different if this is paid work or home study. People in this group, myself included, are very happy to encourage people to learn about embedded development. We are a good deal less keen on helping someone do a professional job for which they are not qualified. (Well, there are some people here ready to do that - but they will want paid for their consultancy!)
Reply by srao October 20, 20152015-10-20
>On 20/10/15 00:22, srao wrote: >>> On 2015-10-17, rickman <gnuarm@gmail.com> wrote: >>>> On 10/16/2015 7:33 PM, srao wrote: >>>>>> Did something like this:- >>>>>> >>>>>> while(1) >>>>>> { >>>>>> >>>>>> for (N loops) //togggle watchdog >>>>>> { >>>>>> //port1 clear bits >>>>>> Set bit on watchdog PIN >>>>>> outport(0x00xx,a); >>>>>> } >>>>>> >>>>>> for (N loops) >>>>>> { >>>>>> //port1 clear bits >>>>>> //Clear bit on watchdog PIN >>>>>> outport(0x00xx,a); >>>>>> } >>>>>> --------------------------------------- >>>>> not sure if I am doing something wrong here. the above code does
not
>>>>> toggle the Port pin. is there a better way to solve this? >>>> >>>> Where do you change the value written to the port? You don't even
show
>> >>>> where you set the value of 'a' initially. >>>> >>> >>> The OP _really_ needs to show us _actual_ code not the above pseudo >> code. >>> >>> Also, the above sequence "feels" really wrong to me. Why is the port >>> pin being set N times and then cleared N times ? >>> >>> With a watchdog you are supposed to send a specific sequence _once_ >>> every time you decide to report that you are still alive and not
stuck.
>>> >>> Simon. >>> Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP >>> Microsoft: Bringing you 1980s technology to a 21st century world >> >> >> >> The exact source code is as below. This lies within main() >> >> >> while(1) >> { >> >> for (i=0;i<2000;i++) >> { >> int p1dir=inport(0x0050); //clear PD5 bit PXDIR
register
>> p1dir &= ~(1 << 5); >> >> int p1con=inport(0x0054); //clear PC5 bit in PXCON >> register >> p1con &= ~(1 << 5); >> >> int b=0x20; //toggle watchdog >> int a=inport(0x0056); >> a&=~b; >> outport(0x0056,a); >> } >> >> for (i=0;i<2000;i++) >> { >> int p1dir=inport(0x0050); //clear PD5 bit PXDIR
register
>> p1dir &= ~(1 << 5); >> >> int p1con=inport(0x0054); //clear PC5 bit in PXCON >> register >> p1con &= ~(1 << 5); >> >> >> int b=0x20; >> int a=inport(0x0056); >> a|=~b; >> outport(0x0056,a); >> } >> > >I'm having difficulty trying to figure out what you are trying to do, >but I can tell you that no matter what you /think/ you are doing, your >code is /badly/ wrong. It is wrong in a way that indicates you have no >idea what you are doing. (This is constructive criticism aimed at >helping you where you need it most - I am not trying to be insulting.) > >It is time to take a step back, and look at the big picture here. What >are you trying to achieve, and why are you doing it? > >If you are trying to learn about embedded programming, you are going >about it the wrong way - pick a modern, friendly microcontroller and a >decent book (ask here for advice if you like). > >If you are doing this professionally, then it can only be in the context >of maintaining an ancient system. Without a larger context, it is >impossible to judge whether something this old /should/ be maintained, >or whether it would be better to replace it. But it is clear that you >are not qualified for the job - the sooner you accept that and arrange >for a qualified person to handle it, the better for everyone (especially >you). > > >If there is no other possibility than for /you/ to do the programming >here, then at least hire a consultant for a few days to work with you >and show you some of the basics. If you have a strong enough background >in programming or electronics, that might be enough to give you a
chance. I know sometimes its hard to understand a question. Everyone has the right to learn on their own and I am doing my part. These are two simple basic programs for UART configuration and watchdog kick. I was new with this kind of processor as its an old one and never had to deal with a watchdog scenario, I just posted my questions as I was unfamiliar with the environment and as I had only worked with PICS and IAR's. Sorry for the trouble you had. --------------------------------------- Posted through http://www.EmbeddedRelated.com
Reply by David Brown October 20, 20152015-10-20
On 20/10/15 00:22, srao wrote:
>> On 2015-10-17, rickman <gnuarm@gmail.com> wrote: >>> On 10/16/2015 7:33 PM, srao wrote: >>>>> Did something like this:- >>>>> >>>>> while(1) >>>>> { >>>>> >>>>> for (N loops) //togggle watchdog >>>>> { >>>>> //port1 clear bits >>>>> Set bit on watchdog PIN >>>>> outport(0x00xx,a); >>>>> } >>>>> >>>>> for (N loops) >>>>> { >>>>> //port1 clear bits >>>>> //Clear bit on watchdog PIN >>>>> outport(0x00xx,a); >>>>> } >>>>> --------------------------------------- >>>> not sure if I am doing something wrong here. the above code does not >>>> toggle the Port pin. is there a better way to solve this? >>> >>> Where do you change the value written to the port? You don't even show > >>> where you set the value of 'a' initially. >>> >> >> The OP _really_ needs to show us _actual_ code not the above pseudo > code. >> >> Also, the above sequence "feels" really wrong to me. Why is the port >> pin being set N times and then cleared N times ? >> >> With a watchdog you are supposed to send a specific sequence _once_ >> every time you decide to report that you are still alive and not stuck. >> >> Simon. >> Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP >> Microsoft: Bringing you 1980s technology to a 21st century world > > > > The exact source code is as below. This lies within main() > > > while(1) > { > > for (i=0;i<2000;i++) > { > int p1dir=inport(0x0050); //clear PD5 bit PXDIR register > p1dir &= ~(1 << 5); > > int p1con=inport(0x0054); //clear PC5 bit in PXCON > register > p1con &= ~(1 << 5); > > int b=0x20; //toggle watchdog > int a=inport(0x0056); > a&=~b; > outport(0x0056,a); > } > > for (i=0;i<2000;i++) > { > int p1dir=inport(0x0050); //clear PD5 bit PXDIR register > p1dir &= ~(1 << 5); > > int p1con=inport(0x0054); //clear PC5 bit in PXCON > register > p1con &= ~(1 << 5); > > > int b=0x20; > int a=inport(0x0056); > a|=~b; > outport(0x0056,a); > } >
I'm having difficulty trying to figure out what you are trying to do, but I can tell you that no matter what you /think/ you are doing, your code is /badly/ wrong. It is wrong in a way that indicates you have no idea what you are doing. (This is constructive criticism aimed at helping you where you need it most - I am not trying to be insulting.) It is time to take a step back, and look at the big picture here. What are you trying to achieve, and why are you doing it? If you are trying to learn about embedded programming, you are going about it the wrong way - pick a modern, friendly microcontroller and a decent book (ask here for advice if you like). If you are doing this professionally, then it can only be in the context of maintaining an ancient system. Without a larger context, it is impossible to judge whether something this old /should/ be maintained, or whether it would be better to replace it. But it is clear that you are not qualified for the job - the sooner you accept that and arrange for a qualified person to handle it, the better for everyone (especially you). If there is no other possibility than for /you/ to do the programming here, then at least hire a consultant for a few days to work with you and show you some of the basics. If you have a strong enough background in programming or electronics, that might be enough to give you a chance.