check out the fuses, PLL etc. 48Hhz is needed for USBthis is confusing - from what I can see the crystal on the board is 20 Mhz, but the OSC
value in the first bit of code is 48
check out the fuses, PLL etc. 48Hhz is needed for USBthis is confusing - from what I can see the crystal on the board is 20 Mhz, but the OSC
value in the first bit of code is 48
Last edited by towlerg; - 12th May 2015 at 02:09.
It IS confusing. As I said, I made the change to the LCD program that just says Hello World over and over again, but it doesn't work on the keypad program.
I'm still learning this type of code, so the error could be right in front of me and I won't see it. That's why I'm asking for help deciphering this type of coding.
Thanks,
Tony
Demon hit on an issue that comes up here repeatedly. Writing define osc 20 doesn't do the job but define OSC 20 will. I use his method and write the whole define statement in caps like DEFINE OSC 20. That needs to be addressed first.
Absolutely.
From the PBP manual in the "DEFINEs Defined" section.
For the practical PBP user, there are a couple of fundamental points to consider:
1) DEFINEs are CASE SENSITIVE!
All PBP DEFINE parameters are UPPERCASE.
So when you use "osc"' "Osc" "oSc" "osC" "OSc" "oSC" "OsC", PBP will not recognize these as OSC defines and will use the default OSC setting.
ONLY "OSC" will actually tell PBP you are setting the OSC speed.
The correct statement for your program is:
"DEFINE OSC 20"
The Microcode Studio UI will change the "DEFINE" keyword to lower case when it is displayed I.e. "define" but that is only what is displayed in the UI. It does not actually change the text in the file to lowercase. More importantly it does not change the "OSC" parameter. It will leave it as you typed it.
Regards,
TABSoft
Well, that was it. I tried changing the case of define to uppercase, but PBP kept changing it back to lowercase. Never did anything with the OSC. Not sure if it's a programming flaw or done intentionally, but that makes no sense to auto-correct some things that don't matter, but not auto-correct the things that do matter.
Two days I've been working on this, and all for something as simple as case size. I thought it was the other code as I am not familiar with it and was trying to decipher it.
Thanks for everyone's input. Much appreciated.
Tony
ERMEGM,
Glad that got you going.
Yes, the MCS (MicroCode Studio) editor does have a few things that are undesirable, including the one you pointed out about case changing. However, you can configure this behavior in MCS. Go to View-> Editor Options-> Highlighter tab.
At the bottom you will see Reserved Word Formatting.
There you can change the option from "Lowercase All" (default setting) to "Default" which will leave the text as it was entered by the user.
Regards,
TABSoft
Just to reiterate, possibly for future reference:
The reserved word DEFINE can be written any way you like, lower case, upper case, mixed case, whatever. It's WHAT you define (OSC on this case) that's case sensitive. It doesn't automatically mean everything should be UPPER CASE, it means it must match the case of the assembly code constant you're trying to "set". Thankfully all PBP assemnly code constants ARE all upper case.
/Henrik.
But how would you get the timing right with a 20mhz crystal. I thought HS setting means that you run at the crystal speed, and the HS_PLL is typically a multiplier (of 4). IE to get 48 Mhz a 12 Mhz crystal is required, OSC is set to 48 and the fuse set to HS_PLL. - From the pictures of this LAB it's not clear if you can interchange the crystals, which is why I found that confusing.
Malc,
ERMEGM is not using a 18F4550 in the board. He is using a 16F874A.
It's max rate is 20MHz using HS mode.
The 18F4550 is a bit of a different animal as far as I can tell looking at the DS.
It can take a 20MHz input in HSPLL mode that then gets divided by 5 to drive a 4MHz input into the PLL to get a 96MHz PLL clock. You can then select to divided down to 48MHz for the MCU clock. This allows the USB and MCU to run from a common source but at different rates.
Regards,
TABSoft
For me too.
Had to take a look at the 4550 DS to get an understanding of it.
Regards,
TABSoft
Thank you for the insight.
Tony
Bookmarks